Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio Update bundle jarsigner: key associated with key0 not a private key

These are the steps I am taking, in the order presented, to update a published app after fixing a bug, through Android studio:

  1. Fix the bug.

  2. Changed to versionCode 2 and versionName "1.1" on build.gradle (Module)

  3. Generate Signed Bundle

  4. Key-store path is C:\Folder\Folder\Android\MyApp.jks

  5. Both passwords are correct

  6. Key alias: key0 (default as on first time)

But then this error is raised:

Cause: jarsigner.exefailed with exit code 1 :
jarsigner: key associated with key0 not a private key

What could be causing this?

like image 506
jer Avatar asked Jan 04 '19 10:01

jer


4 Answers

"Build" -> "Clean project", then "Generate signed ..." again - worked fine for me

like image 174
Koozy.ua Avatar answered Nov 11 '22 02:11

Koozy.ua


it's simply means that you enter wrong key let me explain

  1. your password for keystore correct
  2. you password for The key is't correct
like image 6
sf7k Avatar answered Nov 11 '22 03:11

sf7k


I had the same issue, I have tried Clean Build and Invalidate Caches/Restart but didn't work. Finally I entered a Wrong KeyStore password then it has shown some error like jarsigner error: java.lang.RuntimeException: keystore load: Keystore was tampered with, or password was incorrect. Then I tried with the Original one and it worked.

like image 2
deepak raj Avatar answered Nov 11 '22 02:11

deepak raj


For those coming to this question to build a release candidate of a React Native app for the Play Store, or if building without Android Studio.

a) Cleaning the project is particularly useful if you've had previous errors in your release packaging:

cd android
./gradlew clean


b) Check to see if your keystore was created correctly, with a valid, exportable certificate embedded inside:

keytool -export -alias your-keystore-alias -file mycertificate.crt -keystore /path/to/keystore 

You will be prompted for the keystore password you used when generating the keystore. If you get a mycertificate.crt file created successfully, there isn't anything wrong with your keystore. It's valid.


c) The not a private key error can also come up if you've not explicitly supplied a key password, and just a store password (as shown below), in your gradle release build properties:

MYAPP_UPLOAD_STORE_FILE=my-app.keystore
MYAPP_UPLOAD_KEY_ALIAS=my-app
MYAPP_UPLOAD_STORE_PASSWORD=keystorePassword
MYAPP_UPLOAD_KEY_PASSWORD=

When generating a signing certificate with keytool, there is an optional argument to generate a separate certificate password, apart from the keystore password. However, if no certificate/key password is supplied, it inherits the keystore password. So in this case, a working set of properties would be:

MYAPP_UPLOAD_STORE_FILE=my-app.keystore
MYAPP_UPLOAD_KEY_ALIAS=my-app
MYAPP_UPLOAD_STORE_PASSWORD=keystorePassword
MYAPP_UPLOAD_KEY_PASSWORD=keystorePassword
like image 1
changingrainbows Avatar answered Nov 11 '22 03:11

changingrainbows