Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ScyDev opened this issue May 22, 2015 · 21 comments
Closed

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

ScyDev opened this issue May 22, 2015 · 21 comments

Comments

@ScyDev
Copy link
Contributor

ScyDev commented May 22, 2015

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

@Calinou

This comment has been minimized.

@ScyDev
Copy link
Contributor Author

ScyDev commented May 22, 2015

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:
#47

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

@ScyDev
Copy link
Contributor Author

ScyDev commented May 22, 2015

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

@ScyDev
Copy link
Contributor Author

ScyDev commented May 22, 2015

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

@ScyDev
Copy link
Contributor Author

ScyDev commented May 22, 2015

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.

@Krzycho666
Copy link
Contributor

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

@godotengine
Copy link
Collaborator

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 notifications@github.com wrote:

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


Reply to this email directly or view it on GitHub
#1957 (comment).

OkamStudio

@mohaalak
Copy link

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" notifications@github.com 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
#1957.

@ScyDev
Copy link
Contributor Author

ScyDev commented Jun 15, 2015

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

@akien-mga
Copy link
Member

@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?

@mohaalak
Copy link

mohaalak commented Jan 2, 2016

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

@akien-mga
Copy link
Member

Thanks!

@set-killer
Copy link

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 ?

@chandujr
Copy link

chandujr commented May 6, 2016

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.

@undeton
Copy link

undeton commented Apr 26, 2019

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.

@unfa
Copy link

unfa commented Feb 7, 2020

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

@Calinou
Copy link
Member

Calinou commented Feb 7, 2020

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

@unfa
Copy link

unfa commented Feb 8, 2020

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.

@Calinou
Copy link
Member

Calinou commented Feb 8, 2020

@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 🙁

@unfa
Copy link

unfa commented Feb 10, 2020

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

@Calinou
Copy link
Member

Calinou commented Feb 10, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants