31

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?

Soutzikevich
  • 991
  • 3
  • 13
  • 29
jer
  • 323
  • 3
  • 5
  • 1
    did you got any solution for this. I am too facing this issue after update android studio to 3.3 – Rakesh Jan 24 '19 at 10:50
  • am still facing this issue, tried all the solutions mentioned here. am using andoird studio gradle plugin 5.1.1 – user93796 May 29 '19 at 16:14

10 Answers10

15

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

Koozy.ua
  • 151
  • 3
7

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
Community
  • 1
  • 1
sf7k
  • 99
  • 1
  • 3
  • the output can be deceiving. no issue with the key, just needed to double check the passwords – plosco Jul 24 '20 at 22:37
2

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.

deepak raj
  • 3,331
  • 1
  • 12
  • 20
1

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
changingrainbows
  • 2,551
  • 1
  • 28
  • 35
0

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.

Vanshaj Daga
  • 2,145
  • 11
  • 18
0

It seems that you are entering wrong password if

"Build" > "Clean project"

doesn't solved your problem.

Try the reference link providing : Click here

kvadityaaz
  • 1,441
  • 1
  • 16
  • 23
0

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.

bam
  • 302
  • 2
  • 10
  • when I run this command it asks for my password, when I put it In it just says "keytool error: java.io.IOException: Keystore was tampered with, or password was incorrect" but if I try and bundle up my app in the wizard I enter the keystone password and its fine as it lets me select which key to work, then shows the error OP mentioned, any idea why this is happening? – AngryDuck Aug 13 '19 at 13:59
0

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.

Big_Chair
  • 2,781
  • 3
  • 31
  • 58
0

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.

reddtoric
  • 568
  • 1
  • 6
  • 13
0

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

JMM MAS
  • 11
  • 4