Android studio Update bundle jarsigner: key associ

2020-06-30 14:15发布

问题:

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?

回答1:

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



回答2:

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


回答3:

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


回答4:

Well i also faced this problem after upgrading to android studio 3.3 and i resolved in 3 steps. But firstly make sure you backup your whole project.

  1. In Android Studio goto File > Project Structure and untick from "use embedded JDK" then click OK
  2. Goto Computer Settings (system settings) (win + pause key) then go to Advanced system settings>Environment variables. if JAVA_HOME not present then add it and set path to your installed JDK. As i couldn't find a direct approach to modify jdk path in my project that is upgraded in some way to android studio 3.3 settings, i did following(for the last step) BUT MAKE SURE YOU MAKE BACKUP BEFORE THIS.
  3. To make sure where i am guiding come to project view, I deleted ".grade", ".idea", "capture", "gradle" folders from the root and "build", "release", "lib" folder from "app" leaving "src" as it is. Deleted root.iml and did not delete app.iml file Then rebuild the project and then created the Signed package.

It went successful after 2 try. To be very honest i did the last step twice by restoring files from backup. As deleting these folders i messed up 1 time.



回答5:

It seems that you are entering wrong password if

"Build" > "Clean project"

doesn't solved your problem.

Try the reference link providing : Click here



回答6:

For those who had no luck with "Clean Project", try changing the key password with the following command in the Android Studio Terminal

keytool -keypasswd -alias yourAliasName -keystore pathToYourKeystoreFile 

afterwards you're prompted for your keystore password and if correct can then change the key password.

I had the same issue, I have both passwords written on a piece of paper and all of a sudden (Android Studio update?) the key password didn't work anymore. Keystore worked, could select the alias, but when generating the signed app, same error as you got.



回答7:

After trying all the solutions here, it either did not work or was too complicated to even make it work.

In the end simply restarting my PC is what helped.



回答8:

Special characters in your password? Read on

(Not 100% sure but) I had special characters in my key password and I decided to remove all double quotes (") only because it might have been the culprit and it worked.



回答9:

Take care of the numbers of caracters of your password : 6 min I have try more than 20 => this is ko 12 is ok

Don't use special car, caps, nums, are enought



回答10:

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.