Godot: export to apk error:"'jarsigner' returned with error #1"

Created on 22 May 2015  Â·  21Comments  Â·  Source: godotengine/godot

This is still an issue with 1.1stable.
Tried Oracle Java 7 and 8.

bug android porting

Most helpful comment

I had this issue (with openJDK 8) and fixed it when generating the debug.keystore with the following command:

keytool -keyalg RSA -genkeypair -alias androiddebugkey -keypass android -keystore debug.keystore -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999 -sigalg MD5withRSA -keyalg RSA

So yes, -sigalg MD5withRSA -keyalg RSA fixed the things...
Should we update the documentation ?

All 21 comments

You need Java 6 (OpenJDK or Oracle Java).

Edit: Java 8 should work now.

For some people it works with Java 7 and 8:
https://www.facebook.com/groups/godotengine/618544398282158/?comment_id=618584098278188&notif_t=like

But the message "'jarsigner' returned with error #1" is utterly unhelpful and no matter what combination I try, it always just says this.

Apparently this has been a problem for a long time:
https://github.com/okamstudio/godot/issues/47

Godot seems to be using the wrong params to jarsigner? This should be fixed.

I just tried it with OpenJDK 6. Same error.

screenshot from 2015-05-22 10 41 55

Created the keystore with:
/usr/lib/jvm/java-6-openjdk-i386/bin/keytool -genkeypair -alias androiddebugkey -keypass android -keystore /home/scydev/Godot Projects/debug.keystore -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999

I ran Godot with -d flag and got this on the console:

jarsigner error: java.security.SignatureException: private key algorithm is not compatible with signature algorithm

When generating the debug keystore it is necessary to specify the following params:
-sigalg MD5withRSA -keyalg RSA

/usr/lib/jvm/java-6-openjdk-i386/bin/keytool -genkeypair -alias androiddebugkey -keypass android -keystore /home/thluks/Godot\ Projects/debug.keystore -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999 -sigalg MD5withRSA -keyalg RSA

Or it won't work with Godot. This is with OpenJDK 6. Might apply to the newer versions as well.

Godot should be able to work with all JDKs and not use specific algos that are not the default of keytool.

I use both versions of Java 7 and 8 with the same effect. They both work for me fine. I don't quite know why does not work to all. I'm on Windows 7

I would love to replicate the jarsigner behavior inside Godot, so people
does not have to download the entire JDK for this and could do simply with
adb, but i don't have time or knowledge for this.

So, help appreciated.

On Fri, Jun 12, 2015 at 6:22 AM, YugoCode [email protected] wrote:

After I run your command Krzycho666, I get "Unrecognized command:
-genkeypair"
Why?

—
Reply to this email directly or view it on GitHub
https://github.com/okamstudio/godot/issues/1957#issuecomment-111426724.

_OkamStudio_

you don't need java 6 .
open the apk file using winrar or zip archiver or ... then delete the META
INF
On May 22, 2015 12:51 PM, "ScyDev" [email protected] wrote:

This is still an issue with 1.1stable.
Tried Oracle Java 7 and 8.

—
Reply to this email directly or view it on GitHub
https://github.com/okamstudio/godot/issues/1957.

For developing it is very useful to deploy directly from Godot to the phone, without first editing the APK file.

@mohaalak suggested that skipping META-INF might solve this issue, and this has just been merged in #2784. Could one of you check if it does fix this jarsigner issue?

@akien-mga I test it with the latest version I don't see this bug anymore you can close this issue.

Thanks!

I had this issue (with openJDK 8) and fixed it when generating the debug.keystore with the following command:

keytool -keyalg RSA -genkeypair -alias androiddebugkey -keypass android -keystore debug.keystore -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999 -sigalg MD5withRSA -keyalg RSA

So yes, -sigalg MD5withRSA -keyalg RSA fixed the things...
Should we update the documentation ?

I had the same issue in OpenJDK 7 and as @ScyDev suggested, I deleted the old keystore file and created a new one with extra parameters and it worked! In my case the keystore file is in the common location ~/.android.

This proleam happen when you give wrong password when generate key.
Fist goto jdk directory to regenerate new keystore:
1: generate key keytool -genkey -v -keystore debug.keystore -alias debug -keyalg RSA -keysize 2048 -validity 10000
2: goto Editor-> Editor Settings > Export > Android.
3:Debug keystore field: Point to keystore file.
4: replace 2 field Debug keystore user: to name that keysore.
Debug keystore password: password when you generate keystore.

It should work.

I have the same error in Godot 3.2, I've followed every answer, remade the keystore a few times over, tried everything, nothing works. If I try to use jarsigner manually to sign my APK, it returns a bunch of Java errors that mean nothing to me:

$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore debug.keystore Game.apk androiddebugkey
Exception in thread "main" java.lang.NoClassDefFoundError: sun/security/ec/ECParameters
        at sun.security.pkcs11.SunPKCS11$P11Service.newInstance0(SunPKCS11.java:1038)
        at sun.security.pkcs11.SunPKCS11$P11Service.newInstance(SunPKCS11.java:980)
        at sun.security.jca.GetInstance.getInstance(GetInstance.java:236)
        at sun.security.jca.GetInstance.getInstance(GetInstance.java:164)
        at java.security.Security.getImpl(Security.java:694)
        at java.security.AlgorithmParameters.getInstance(AlgorithmParameters.java:146)
        at sun.security.x509.AlgorithmId.decodeParams(AlgorithmId.java:121)
        at sun.security.x509.AlgorithmId.<init>(AlgorithmId.java:114)
        at sun.security.x509.AlgorithmId.parse(AlgorithmId.java:372)
        at sun.security.x509.X509Key.parse(X509Key.java:167)
        at sun.security.x509.CertificateX509Key.<init>(CertificateX509Key.java:75)
        at sun.security.x509.X509CertInfo.parse(X509CertInfo.java:699)
        at sun.security.x509.X509CertInfo.<init>(X509CertInfo.java:166)
        at sun.security.x509.X509CertImpl.parse(X509CertImpl.java:1806)
        at sun.security.x509.X509CertImpl.<init>(X509CertImpl.java:197)
        at sun.security.provider.X509Factory.engineGenerateCertificate(X509Factory.java:98)
        at java.security.cert.CertificateFactory.generateCertificate(CertificateFactory.java:339)
        at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:760)
        at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:56)
        at sun.security.provider.KeyStoreDelegator.engineLoad(KeyStoreDelegator.java:224)
        at sun.security.provider.JavaKeyStore$DualFormatJKS.engineLoad(JavaKeyStore.java:70)
        at java.security.KeyStore.load(KeyStore.java:1381)
        at sun.security.tools.KeyStoreUtil.getCacertsKeyStore(KeyStoreUtil.java:119)
        at sun.security.tools.jarsigner.Main.loadKeyStore(Main.java:2038)
        at sun.security.tools.jarsigner.Main.run(Main.java:272)
        at sun.security.tools.jarsigner.Main.main(Main.java:127)
Caused by: java.lang.ClassNotFoundException: sun.security.ec.ECParameters
        at java.net.URLClassLoader$1.run(URLClassLoader.java:360)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:349)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:348)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:430)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
        ... 26 more

@unfa Are you using jarsigner from JDK 8 (and not a newer version)?

Turned out I wasn't. I had JDK 7 installed. I want to write down all the things I've learned today so others an use them or I can use them later, because there's a bunch of pitfalls with Android exporting and once-click deployment.

@unfa We should try to perform some kind of JDK version check before exporting to Android. However, jarsigner doesn't seem to have a way to print its version number or the JDK version number :slightly_frowning_face:

Maybe there could be w suggestion for the user to check the version?
Could Godot also download this binary itself?

Could Godot also download this binary itself?

This is technically feasible, but last time I asked, @akien-mga (or someone else) wasn't too keen on making Godot download the JDK or Android SDK automatically when needed.

If we decide to go this route, AdoptOpenJDK is a good source of compiled OpenJDK 8 binaries for various platforms.

Was this page helpful?
0 / 5 - 0 ratings