Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Error building Player: UnityException: APK Signing Failed! Failed to sign APK package

Discussion in 'Android' started by quitebuttery, Mar 5, 2012.

  1. quitebuttery

    quitebuttery

    Joined:
    Mar 12, 2011
    Posts:
    327
    So I have a legit keystore, I even used the Unity interface to create a new key in it, and it picks it up. So my passwords are correct. But when I try to sign my APK I get this error in an alert box:


    Error building Player: UnityException: APK Signing Failed!
    Failed to sign APK package. See the Console for details.

    When I check the console, all it says is that. No information. Where can I find out why the APK signing process is failing?
     
  2. DFiable

    DFiable

    Joined:
    Mar 3, 2012
    Posts:
    27
    Check to make sure debug is unchecked.
    Double check that the keystore file is loaded correctly before you sign.(Sometimes I've noticed that even though I click on the keystore file
    it doesn't load)
    Make sure you select the correct alias before puting in your password.

    just a few suggestions.
     
    shauli21 likes this.
  3. quitebuttery

    quitebuttery

    Joined:
    Mar 12, 2011
    Posts:
    327
    I assume you mean "Development Build" is unchecked? Yeah that's unchecked.

    The keystore is loaded as far as I can tell--when I browse, and then pick the alias there's a pause and all the aliases show up. Still doesn't work.
     
  4. DFiable

    DFiable

    Joined:
    Mar 3, 2012
    Posts:
    27
    Try closing Unity and restarting. Even shutting down your computer. It should work from what your describing.

    Did you type in both passwords?
     
  5. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Posts:
    1,217
    This problem was discused somewhere else here in the forum. It has somethig to do with the Path to the Java JDK and the JAVA_HOME Enviromentvariable wasn't either set or points to a wrong directory.

    Hit Win+Pause > Advanced/Extended Systemsettings (dunno the exact term, got german Windows here) > Extra > Enviromental variables > in "User Variables for <USERNAME>" list look for JAVA_HOME and change it to the path where your JDK is installed (the bin folder, i.e. C:\Program Files\Java\jdk1.6.0_20\bin\ )
     
  6. quitebuttery

    quitebuttery

    Joined:
    Mar 12, 2011
    Posts:
    327
    THANKS TSENG!!!!

    I'm almost there--I set the JAVA_HOME to this:

    http://www.mehtanirav.com/2008/09/02/setting-java_home-on-mac-os-x-105/

    Indeed JAVA_HOME wasn't set at all.

    Now it's failing at entering the password. I have the passwords set properly in Player Settings, but I get this error:

    --

    jarsigner: you must enter key password
    Picked up JAVA_TOOL_OPTIONS: -Xmx2048m
    Enter Passphrase for keystore:

    UnityEngine.Debug:LogError(Object)
    PostProcessAndroidPlayer:SignAndroidPackage(String)
    PostProcessAndroidPlayer:postProcess(BuildTarget, String, String, String, String, String, String, BuildOptions)
    UnityEditor.HostView:OnGUI()

    --
     
  7. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Posts:
    1,217
    There are two passwords. One for the keystore and one for the key/signature alias
     
  8. quitebuttery

    quitebuttery

    Joined:
    Mar 12, 2011
    Posts:
    327
    As far as I can tell, both passwords are correct. I even created a new one and made sure I had the password correct to no avail. I at least know the keystore password is correct because it shows the aliases. But I'm pretty sure the alias password is correct too. Any ideas?
     
  9. quitebuttery

    quitebuttery

    Joined:
    Mar 12, 2011
    Posts:
    327
    Funny--with JAVA_HOME set, now it's back to giving me the original error. Lovely.

    Uniity support suggested setting the CLASSPATH, which wasn't set. So I set it to this:

    $HOME/Library/Java:$NEXT_ROOT/Library/Java:$NEXT_ROOT/System/Library/Java:$NEXT_ROOT/Network/Library/Java:$NEXT_ROOT/System/Library/Frameworks/JavaVM.framework/Classes/classes.jar:$NEXT_ROOT/System/Library/Frameworks/JavaVM.framework/Classes/ui.jar

    But I still get the same error.

    Can I just sign the APK with the keytool on the command line?
     
  10. quitebuttery

    quitebuttery

    Joined:
    Mar 12, 2011
    Posts:
    327
    I've been talking with Unity support about this and they have no answers and apparently no solution.

    I tried my keystore in Eclipse and signed a Java app with the same set of passwords no problem.

    But when I try to sign the APK in Unity I still get that error:

    arsigner: you must enter key password
    Picked up JAVA_TOOL_OPTIONS: -Xmx2048m
    Enter Passphrase for keystore:

    UnityEngine.Debug:LogError(Object)
    PostProcessAndroidPlayer:SignAndroidPackage(String)
    PostProcessAndroidPlayer:postProcess(BuildTarget, String, String, String, String, String, String, BuildOptions)
    UnityEditor.HostView:OnGUI()

    This is the version of Java I'm using:

    java -version
    Picked up JAVA_TOOL_OPTIONS: -Xmx2048m
    java version "1.6.0_29"
    Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11D50b)
    Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)

    Its 1.6 -- which is the correct version. Should I downgrade to 32-bit? Seems ridiculous, but I guess that's my only option at this point before I start looking at UDK or something.
     
  11. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Posts:
    1,217
    Worth a try. I know older versions of Unity had problems with JDK 1.7 or the 64-bit versions of JDK 1.6. JDK 1.6 32-bit worked for basically everyone
     
  12. quitebuttery

    quitebuttery

    Joined:
    Mar 12, 2011
    Posts:
    327
    Can I install the 32-bit version in a different folder and point JAVA_HOME at it? Or do I have to uninstall 64-bit java and install 32-bit to get Unity to pick it up properly?
     
  13. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Posts:
    1,217
    Never tried it. Though, there is no real advantage of having 64 bit version of it anyways. 98% of the Applications don't even profit form being 64 bit over 32 bit, unless you want to open files wihch are greater than 2 GB or you need more than 2 GB of memory :p
     
  14. quitebuttery

    quitebuttery

    Joined:
    Mar 12, 2011
    Posts:
    327
    FOUND IT!!!!!!!!!!

    Ok--so here's the deal. I talked to an Android guru friend of mine at GDC, he gave me the name of one of the super duper Android engineers at Unity. He suggested I hunt him down at the booth. I did, and we spent 15 minutes looking at my machine. He was mystified--but it seemed that Unity was picking up a bogus JAVA_TOOLS_OPTIONS setting from somewhere that was probably causing the command line compilation to fail.

    The setting was: -Xmx2048m (as you see in the error)

    We looked at my .bash_profile, but didn't see it. He had to go to a meeting, but that was enough clues. He also said worst case, you can remove the manifest folder from the APK (it's just a zip file) and just sign it on the command line...which works. But what a pain!

    When I got home from GDC, I was checking out my system and found I had an environment.plist file in my hidden .MacOSX folder. I made this years and years ago to boost the memory for the JRE back in my Flash days and forgot about it. No wonder we didn't see it in my .bash_profile file.

    I deleted this plist, rebooted my Mac, and now it creates a signed APK!!!!!!

    Pretty obscure bug. I think it would help if Unity logged all of the shell command activity it does while building APKs etc. The editor.log doesn't show really what's going on under the hood sometimes.
     
    lkleon93 likes this.
  15. Evil-Dog

    Evil-Dog

    Joined:
    Oct 4, 2011
    Posts:
    134
    I have that problem on windows with Unity 3.5.0f5, do you guys have any more pointers to fix that? What would be the PC equivalent to your solution? Ideas?
     
  16. Tropicaya

    Tropicaya

    Joined:
    Jul 7, 2012
    Posts:
    10
    I went into windows/system32/ and selected properties on java.exe; I then checked run as administrator
    (Win 8)
     
  17. pioner40

    pioner40

    Joined:
    Oct 19, 2013
    Posts:
    1
    well I have done all of this but still the same problem ... more solutions please ! :)
    (windows 7)
     
  18. lewis26009

    lewis26009

    Joined:
    Aug 29, 2015
    Posts:
    1
    same i have the same problem but with windows 10
     
  19. JulioKasper

    JulioKasper

    Joined:
    Sep 4, 2017
    Posts:
    1
  20. Sihugar

    Sihugar

    Joined:
    Apr 6, 2018
    Posts:
    1
    //Debug.log(En Español);

    El problema es el JDK, tenéis que poner en la ruta de preferencias, una que trabaje con 32 bits, o en tal caso, una que sea compatible con unity! ejemplo: hay casos en que el JDK para windows 10 = Java(jdk v.10) no llega trabajar aún en Unity, así que por ahora trabajar con una versión anterior a la JDK que tengaís... la cual os da por error...

    //Debug.log(In English);


    The problem is the JDK, you have to put in the preferences path, one that works with 32 bits, or in that case, one that is compatible with unity! example: there are cases in which the JDK for windows 10 = Java (jdk v.10) does not work yet in Unity, so for now work with a version before the JDK that you have which gives you by mistake.
     
    Dadusak likes this.
  21. shauli21

    shauli21

    Joined:
    Feb 15, 2022
    Posts:
    8
    for me its working only when the debug is checked
     
    Last edited: Jan 11, 2024