Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to export signed APK in Android Studio

When I use keytool -list -keystore /path/to/keyfile.jks and give my password, I'm able to see the entry there, but when I use the same password while trying to Generate signed APK using the same password, I get the error

Cannot load key store: Keystore was tampered with, or password was incorrect

Please help!

like image 960
Sankalp Sharma Avatar asked Jul 27 '14 05:07

Sankalp Sharma


People also ask

What is the difference between APK and signed APK?

Export Signed apk means you get the apk and it will provide the option to make the sign apk with existing keystore. Android requires that all apps be digitally signed with a certificate before they can be installed.

Can I upload unsigned APK to play store?

It is not possible to publish unsigned APK on Google Play. 5) Generate new signed APK using keyStore file provided by your developer 6) after generating new signed APK, you can update your existing google play application by new APK.


1 Answers

Got the answer after 20 hours of tireless searching. Apparently there is some issue with the character '&' in passwords as mentioned here https://code.google.com/p/android/issues/detail?id=36350 Although in my case, the character was '@'.

For anyone who gets stuck, here is what I did (and what should work for them too)

  1. I used the keytool -keypasswd -alias <key_name> -keystore mykeystorek.jks command to change password for my key alias password.
  2. Since I suspected my original file had some issues, I thought it best to export the keys to another file. I did that using keytool -importkeystore -srckeystore my.keystore.jks -destkeystore new.keystore -deststoretype pkcs12 followed by keytool -importkeystore -srckeystore new.keystore -srcstoretype pkcs12 -destkeystore final.keystore -deststoretype jks.

What this does is, export the original keystore values in PKCS12 format, and then back to Java Keystore format in the filename final.keystore. In all these commands, the prompt asked for new destination password, which I carefully chose, avoiding @ and &.

And it works now! As indicated in the link shared above,this seems to be due to some update pushed in SDK Tools 20. I know it's bad. The other app owners seem pretty pissed at Google too. :(

like image 104
Sankalp Sharma Avatar answered Oct 20 '22 18:10

Sankalp Sharma