- Home /
Unable to Create or Sign APK File for Android
Hi,
My Question is.... What am I missing?!? What's wrong!!!!!!!!!!!!!!!
I have been trying for quite some time to build to Unity, and everytime I do, it keeps failing over and over. I have tried several things, and to no avail. I keep getting a "Failed to Sign APK Error".
I have JDK-9 installed, with Environment Path set to JDK-9, and unity external Tools set to JDK-9.
In Environment Variables I have:
Variables: JAVA_HOME Value set to "..\Java\jdk-9\bin" (I have also tried "..\Java\JDK-9"
Variables: PATH Value set to "..\Program Files\Java\jdk-9\bin"
SYSTEM VARIABLES:
Variable JAVA_HOME set to "..\Java\jdk-9\bin"
Variable PATH set to "..\Java\jdk-9"
I have Android SDK, Build Versions 16, 25, 26, full. I have NDK as well (although i dont think its needed).
UNITY
In Unity I have UnityPreferences / External Tools set too:
Android SDK : "../AppData/Local/Android/sdk"
JDK: "../Java/jdk-9"
NDK: "../android-ndk-r10e"
PLAYER SETTINGS:
Version: 0.1.0
Min API: 4.1
Bundle Version Code: 1
Target API: Automatic
Script Runtime: .NET 3.5 Stable
Scripting Backend: Mono
API Compatibility: 2.0
Keystore is browsed to correct directory. keystore password is correct (attempted to remake it 4x incase it was wrong, also have keystore pass, and key-pass matching just in case) I have tried Unsigned, and Signed Keys.
I have tried both Internal, and Gradle. (gradle is still to new to find enough info on it, so only tried once and stopped).
This app is not on the google play store, just simply testing. I have tried signing it in different ways, matching passwords, etc, and it still fails. Below is the error I get.
I have also tried updating the Android SDK Tools Folder in the Android SDK directory to previous version of 25.2.5 as indicated in several forum posts like this one:
https://stackoverflow.com/questions/42538433/not-finding-android-sdk-unity
CommandInvokationFailure: Failed to sign APK package. C:\Users\alexm\AppData\Local\Android\sdk\build-tools\26.0.1\apksigner.bat sign --ks "D:/1 - Unity Projects/UntilYouDie/UntilYouDie/DeploymentDocs/user.keystore" --ks-pass pass:"fuzzysmurf123" --ks-key-alias "until you die" --key-pass pass:"fuzzysmurf123" "D:\1 - Unity Projects\UntilYouDie\UntilYouDie\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(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source) Exception in thread "main" ] stdout[
] exit code: 1 UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) UnityEditor.Android.PostProcessor.Tasks.TasksCommon.Exec (System.String command, System.String args, System.String workingdir, System.String errorMsg) 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) UnityEditor.HostView:OnGUI()
I'm at a loss. any help would be appreciated.
Answer by EdwinChua · Oct 02, 2017 at 02:22 AM
Hi, I think your problem is with this:
com/android/apksigner/ApkSignerTool : Unsupported major.minor version 52.0 at ...
Please refer to the solutions described here: https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi
You know, I think that did the trick, and the project Builds now, but wont install on the phone. I now get a:
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
Answer by pazgamestudio · Mar 05, 2018 at 03:25 PM
Add the variable as shown below. change to new version of your java ,for me is: jdk1.8.0_65 (make sure restart pc) good luck.:)
Answer by lingmaaki · Oct 30, 2019 at 12:35 PM
It is because of Java version mismatch. Unsupported major.minor version error happens when you compile your projects on higher version of java(e.g. jdk 1.8) and then run it on a lower version (e.g. jdk 1.7). Depending on your situation, you have two ways to resolve this error: compile your code for an earlier version of Java, or run your code on a newer Java version. Sometimes you may have more than one version of Java SDK installed in your machine. Make sure the application you are running is pointing to the right or highest version available . It is better you need to install both JRE/JDK with the same version.