Search Unity

Unity 2017.1 Android build error

Discussion in 'Android' started by John-Lisenby, Jul 11, 2017.

  1. ramphulneillpartners

    ramphulneillpartners

    Joined:
    Jul 30, 2017
    Posts:
    9
    Hi all - I am am at a complete standstill re. this so went back to Unity SimpleMobilePlaceHolder asset to test build process as described un Unity Tutorial here. But still having probs.

    Android SDK tools Version is one here (as part of studio). I re-installed everything 12 hours ago so it is up-to-date.

    Unity was updated 12 hours ago to version 5.6.3p2

    I have also tried replacing tools folder directory with older version of tools (see here for link to older version of tools for version) as many have tried before.

    Obviously I have double checked the paths are correct for JDK and SDK
    (C:\Users\Tim\AppData\Local\Android\sdk and C:\Program Files\Java\jdk-9).

    I am running everything else on normal hardware- nothing special on Windows 10. Target platform is Android Marshmallow Galaxy S8.

    Any help will be much appreciated!

    tim.
     
  2. ramphulneillpartners

    ramphulneillpartners

    Joined:
    Jul 30, 2017
    Posts:
    9
    This has finally worked for me after reinstalling multiple times and wasting last 8 hours of my life!

    Unity 5.6.2f1
    Windows 10
    Java SE 8u144 (http://www.oracle.com/technetwork/java/javase/downloads/index.html)
    Android 7.0 API 24 Revision 2
    Android SDK Build-Tools 26.0.2
    Android SDK Platform-Tools 26.0.0
    Android SDK Tools 26.1.1

    Yes - it seems later editions of Java not recognised by later editions of Unity.

    Time for a drink :)
     
  3. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,067
    We're working on JDK9 support.
     
  4. Syndran

    Syndran

    Joined:
    Jul 19, 2016
    Posts:
    9
    Any idea how long this will take?

    Please modify your tutorial to show that you can NOT use the latest java SDK (please see associated question that has been waiting moderation for 2 weeks now RE Android building with unity 2017 and Java SDK 9)
     
  5. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,067
  6. ilmario

    ilmario

    Joined:
    Feb 16, 2015
    Posts:
    69
    A workaround until a fixed Android SDK Build Tools 26.x build is available is to copy build-tools/25.0.3/apksigner* and build-tools/25.0.3/lib/apksigner.jar to build-tools/26.0.0/

    This worked for me, finally, thank you! Feels like such waste of time fighting hours with issues like these. I have Unity 2017.1.1p3 on Mac OSX. JDK was 8.x, luckily.
     
  7. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,067
    I would rather recommend updating to latest build-tools (26.0.2 at the moment) rather than doing the copy hack.
     
  8. DuanGrass

    DuanGrass

    Joined:
    Oct 24, 2017
    Posts:
    3
    I still encountered the same problem, SDK updated to 26.0.2
    unity2017.2.0f3
     
    JunaidGhani likes this.
  9. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,067
    What is "the same problem"?
     
  10. DuanGrass

    DuanGrass

    Joined:
    Oct 24, 2017
    Posts:
    3
    CommandInvokationFailure: Failed to sign APK package.
    D:\Android\sdk\build-tools\26.0.2\apksigner.bat sign --ks "E:/B_6-5+2017.2.0f3/20171024_v1.0.0_n1_1st/touch.keystore" --ks-pass stdin --ks-key-alias "tm" --key-pass stdin "E:\B_6-5+2017.2.0f3\20171024_v1.0.0_n1_1st\Temp/StagingArea/Package.apk"

    stderr[
    java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    Exception in thread "main"
    ]
     
  11. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,067
    @DuanGrass this is not "the same problem". Please install JDK8 from Oracle website and configure JDK path in the Editor preferences. Looks like you're using JDK7 and it's not supported by Android tools anymore. I'm adding a check to catch an error like this.

    Make sure you don't install JDK9 instead - it's not supported by Android tools as well!
     
  12. DuanGrass

    DuanGrass

    Joined:
    Oct 24, 2017
    Posts:
    3
    @Unity Technologies upload_2017-10-26_9-7-13.png

    CommandInvokationFailure: Failed to sign APK package.
    D:\Android\sdk\build-tools\26.0.2\apksigner.bat sign --ks "E:/B_6-5+2017.2.0f3/RWWHQL_SXJHB_171026_v1.0.5_n5/touch.keystore" --ks-pass stdin --ks-key-alias "tm" --key-pass stdin "E:\B_6-5+2017.2.0f3\RWWHQL_SXJHB_171026_v1.0.5_n5\Temp/StagingArea/Package.apk"

    stderr[
    java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    Exception in thread "main"
    ]
    stdout[

    ]
    exit code: 1
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.Command.RunWithStdin (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg, System.String[] input)
    UnityEditor.Android.PostProcessor.Tasks.TasksCommon.Exec (System.String command, System.String args, System.String workingdir, System.String errorMsg, System.String[] stdin)
    UnityEditor.Android.PostProcessor.Tasks.BuildAPK.SignPackage (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    UnityEditor.Android.PostProcessor.Tasks.BuildAPK.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
  13. NinjaCat

    NinjaCat

    R&D Minion Unity Technologies

    Joined:
    Aug 22, 2013
    Posts:
    69
    This error is usually an indicator of an old version of JDK, so I suspect it's trying to use the wrong JDK from somewhere. Do you have any older JDK versions installed on the machine? Perhaps you've also set the JAVA_HOME system environment variable? Any info on your android development setup is appreciated.
     
  14. LightOwl

    LightOwl

    Joined:
    Mar 28, 2017
    Posts:
    15
    I did that and was able to build but then ran into another snag. I'm building for Oculus and it doesn't support Signature Scheme 2. Now what do I do? Is there something I can do through Unity? androidapknot supported.PNG
     
  15. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,067
    Moreover - probably jdk7/bin is in PATH.
     
  16. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,067
    @LightOwl we disabled signature v2 for Oculus builds in a patch release 2017.1p5. Please update your Unity.
     
  17. gamepower7

    gamepower7

    Joined:
    May 16, 2017
    Posts:
    22
    this problem was fixed in unity 2027.2
     
  18. hendra17

    hendra17

    Joined:
    Nov 6, 2017
    Posts:
    1
    i have problem with build android project

    Failed to compile resources with the following parameters:
    -bootclasspath "C:/Program Files (x86)/Android/android-sdk\platforms\android-27\android.jar" -d "C:\Users\mahendra\Documents\New Unity Project 4\Temp\StagingArea\bin\classes" -source 1.6 -target 1.6 -encoding UTF-8 "eu\kudan\androidar\R.java" "eu\kudan\ar\R.java"
    warning: [options] source value 1.6 is obsolete and will be removed in a future release
    warning: [options] target value 1.6 is obsolete and will be removed in a future release
    warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
    3 warnings

    and

    UnityException: Resource compilation failed!
    Failed to recompile android resource files. See the Console for details.
    UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message, UnityEditor.Android.CommandInvokationFailure ex)
    UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuildPointToConsole (System.String title, System.String message)
    UnityEditor.Android.PostProcessor.Tasks.BuildResources.CompileResources (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    UnityEditor.Android.PostProcessor.Tasks.BuildResources.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry)
    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (BuildPostProcessArgs args)
    UnityEditor.PostprocessBuildPlayer.Postprocess (BuildTargetGroup targetGroup, BuildTarget target, System.String installPath, System.String companyName, System.String productName, Int32 width, Int32 height, System.String downloadWebplayerUrl, System.String manualDownloadWebplayerUrl, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.BuildReporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:186)
    UnityEditor.HostView:OnGUI()


    how fix thi ?
     
  19. herosuperman

    herosuperman

    Joined:
    Nov 9, 2017
    Posts:
    7
    i m getting these errors while building the app with vuforia sdk.
     

    Attached Files:

  20. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,067
    @hendra17 are you using JDK9?
    Is proguard enabled?
     
  21. cephalo2

    cephalo2

    Joined:
    Feb 25, 2016
    Posts:
    218
    [Solved - had to uninstall Java 9]

    I am getting the same error that some in this thread are getting.
    The java jdk folder is called jdk1.8.0_152 which is the latest version of Java 8 I believe.
    Android SDK tools is 26.1.1

    I also tried the jre that is embedded in Android Studio with the same result.

    mandInvokationFailure: Unable to list target platforms. Please make sure the android sdk path is correct. See the Console for more details.
    C:/Program Files/Android/Android Studio/jre\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="C:/Users/rjm/AppData/Local/Android/sdk\tools" -Dfile.encoding=UTF8 -jar "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -

    stderr[
    Error:Invalid command android
    ]
    stdout[

    ]
    exit code: 64
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.AndroidSDKTools.RunCommandInternal (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.AndroidSDKTools.RunCommandSafe (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
     
    Last edited: Nov 15, 2017
  22. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,067
    Which Unity version is this?
     
  23. cephalo2

    cephalo2

    Joined:
    Feb 25, 2016
    Posts:
    218
    I solved it via the 'Java 9' thread. I had installed the latest version (as instructed :p) then after a struggle installed Java 8, but pointing the path in Unity Preferences to Java 8 wasn't enough because of the windows PATH variable. I had to uninstall Java 9, now I can build.
     
    Yury-Habets likes this.
  24. Cloppi

    Cloppi

    Joined:
    Sep 16, 2015
    Posts:
    2
    Thank you guys for all of your answers. That's all is quite useful. But a have a little different problem after the build.
    When I've got Cardboard and GearVR builds - this time the apps are crashing at launch. I've tried to create an empty project with the basic settings, builds are maded, but after install the .apk - the app is closing at start. I'll try to get the log later, but maybe you already have an idea, why that happens?
    On 5.6.3 version all was good, but now .apk builds not working.
    Maybe there are some additional settings, related to new 2017.2 beta. What you think about that?
     
  25. zxpt001

    zxpt001

    Joined:
    Dec 14, 2017
    Posts:
    1


    HOW TO FIX ITS ?
    PLEASE HELP ME ALL FUTURE WAS INSTALED
     
  26. Tiebo

    Tiebo

    Joined:
    Apr 26, 2017
    Posts:
    10
    This worked for me too, just created a new keystore with more simple password.
    Thanks, this finally got my build working after half a day!
     
  27. Deleted User

    Deleted User

    Guest

    Hello Everyone,

    I got even weirder issue and it started with Unity 2017.2.1 and happening with Unity 2017.3.0f3 as well and the error is, the APK builds successfully as usual but when I try to install it on my phone, the installation fails saying apk is corrupted. Please refer to pic attached and help me

    Thanks & Regards,
    Bhanu
     

    Attached Files:

  28. fausto_alberto

    fausto_alberto

    Joined:
    Jan 11, 2018
    Posts:
    1
    Gracias por la solución en Unity 2017.3 se debe trabajar con el JDK 8

     
  29. kofe

    kofe

    Joined:
    Aug 4, 2015
    Posts:
    4
    Worked for me
     
  30. Zuicis

    Zuicis

    Joined:
    Mar 14, 2014
    Posts:
    11
    OS WIN10
    Android sdk build tools - latest by unity target (27) (installed versions on android studio: 26.0.0 - 28.0.0-rc1)
    Unity version: 2017.4.1f1

    Java: jdk1.8.0_144 - works
    Java: jdk1.8.0_151 - works
    Java: jdk1.8.0_162 - works

    Java: jdk-9.0.4 - failed to compile resources...
    Java: jdk-10 - failed to compile resources...
     
  31. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,067
    https://forum.unity.com/threads/java-9-jdk-9-support-by-unity-android.499354/
     
  32. Oliversgame

    Oliversgame

    Joined:
    Sep 17, 2017
    Posts:
    1
    Disable the built-in Ads extension in the Services >Ads menu. Its worked for me
     
  33. JunaidGhani

    JunaidGhani

    Joined:
    Nov 14, 2017
    Posts:
    4
    I am getting the same error :)
    Unity 2017.2.0f3
    JDK Version 1.8.0

    It's driving me crazy this time, the last time probably some 4 months ago I encountered the same error and I deleted all files in "android-sdk-windows\build-tools" below 2016.0.2 and it worked. It's not working this time, the only difference is this time I have set JAVA_HOME environment variable manually because it wasn't there at all when I checked.

    Kindly see the image attached for details into error.
     

    Attached Files:

  34. JunaidGhani

    JunaidGhani

    Joined:
    Nov 14, 2017
    Posts:
    4
    Solved! after playing with it for many hours.

    Someone viewing this thread might find it helpful later on...

    1: Create an empty project (So it build fast)

    2: Start deleting (moving it to a different place is a better option) SDK build tools folders from bottom to top (latest unto old).
    For example:
    Path: "android-sdk-for-unity/build-tools/"
    Now delete 28.0.0-preview (as it is the latest SDK build tool in my case, in your case it might be different depending on the SDK version. But the idea is to start from the latest)

    3: Build apk and check if the problem is solved and if not delete another folder from SDK Build tools (at the bottom) and build again and carry on until the bug/error is fixed.

    I am attaching an image for better understanding
     

    Attached Files:

  35. reddtoric

    reddtoric

    Joined:
    Mar 7, 2017
    Posts:
    6
    Tagging on this, I'm not 100% sure because I removed the build tools API 25's and 26's after I tried this. Although my error was "key password incorrect" / "key associated with <key alias> not a private key", I had special characters in my key password and I decided to remove all double quotes (") only and it worked.
     
    Last edited: Aug 18, 2019