27

I am trying to generate a signed APK by using the built-in widget in Android Studio v1.4.

However, I got this annoying error

Error:Execution failed for task ':app:packageRelease'. Failed to read key cckey from store "C:\Users\Lancelot\Desktop\release.jks": Keystore was tampered with, or password was incorrect

I was able to retrieve my key alias like the below screenshot enter image description here

(In order to get to here, the key store password must be correct; otherwise it'll show error)

Then I typed in my key password but no luck on signing the APK... I even tried changing the key password using the command line keytool -keypasswd -alias cckey -keystore C:\Users\Lancelot\Desktop\release.jks. By running this I need to enter old password correctly before entering new password, which all went through; this proves that key password wasn't wrong at the first place.

So question is, if my key store password, key alias, and key password are all correct, what's wrong with it then??

Lancelot
  • 1,265
  • 2
  • 16
  • 26

16 Answers16

27

I had a similar problem while updating my app. The keytool was not reading the correct keystore file and instead pointing to an older keystore file that I created months ago and not used. Searched for some solutions online but didn't find one. Almost gave up but I thought about cleaning the project by clicking Build then Clean Project. This last resort worked for me.

15

Apparently I just found another post posted few months ago that solved my issues I struggled for days...

Simply need to change the keystore and key alias password to be the same for it to work. Though I still don't know why the same keystore worked before when I was publishing updates; then not working anymore until I changed the passwords.

If anyone has answer for that, please let everyone know!

Community
  • 1
  • 1
Lancelot
  • 1,265
  • 2
  • 16
  • 26
  • You're better off without key alias passwords altogether. Java does not support them very well at all. – user207421 Oct 12 '15 at 02:03
  • I've seen other posts where devs have said that Gradle 1.3.1 works. It appears that since then, Gradle has been broken. There's two issues outstanding (**4 MONTHS OLD NOW!**): https://code.google.com/p/android/issues/detail?id=188574 and https://code.google.com/p/android/issues/detail?id=187532 – Someone Somewhere Feb 04 '16 at 12:44
  • 3
    is a nonense, if you change, alias and key, you will get a duplicates in google play ! and you can't overwrite your old app –  Apr 22 '16 at 08:16
  • Yep, that was it, i forgot it. – Ronen Festinger Feb 16 '17 at 21:46
  • 1
    I was struggling with the same issue, what I was doing wrong was passing Store password to Key word, and Key Password to Store password. This explains why using same password works. – tanni tanna Mar 08 '18 at 11:21
8

Apparently Google decided to set the default keystore password to be android.

The keytool utility prompts you to enter a password for the keystore. The default password for the debug keystore is android. The keytool then prints the fingerprint to the terminal.

See https://developers.google.com/android/guides/client-auth

TechCrystal
  • 129
  • 1
  • 5
7

I've just had the same problem, and I am 100% sure of my password. I found the solution directly by adding -storepass in the command line. Using this command did the trick:

keytool -list -v -keystore C:\....\keystore.jks -storepass HereMyPassword -alias HereMyAlias
Leigh
  • 28,424
  • 10
  • 49
  • 96
JPhi Denis
  • 197
  • 3
  • 5
  • 1
    For me it appears that the only thing that was wrong is the key alias value. so `keytool -list -v -keystore myFile.jks -storepass 'somePassword'` worked since I was able to see the key alias – Alon Kogan Sep 11 '17 at 19:12
5

how i solved the same problem with android studio 2.2.3

Android studio >> file > project structure

find your project under the modules on left side and select it and click the signing tab. then you can create a new config by clicking green plus icon and fill all the credentials on the signing with existing keystore key. (make sure that your "key elias" "key password" and "Store password" should same previously used with the same key store now using)

then go to the flavors tab and select created config file as Signing config.

again go to the build types tab in and select created config file as Signing config.

and ok to finish the task

happy coding :)

Dinithe Pieris
  • 1,618
  • 3
  • 27
  • 41
5

In my case, I was copying and pasting the keystore and key passwords from Evernote and Android Studio wasn't handling it correctly. After typing the passwords manually, I was able to generate the APK.

Thomas Elliot
  • 599
  • 7
  • 11
4

Make sure there are no blank spaces after your constants definitions:

MYAPP_RELEASE_STORE_FILE=mykeystore.keystore
MYAPP_RELEASE_KEY_ALIAS=keyalias
MYAPP_RELEASE_STORE_PASSWORD=pass
MYAPP_RELEASE_KEY_PASSWORD=pass
IKavanagh
  • 5,704
  • 11
  • 38
  • 44
Jk33
  • 654
  • 1
  • 7
  • 21
1

My problem was I set the store password in the keyPassword and the key password in the storePassword and changing the passwords one by another the problem was solved.

pableiros
  • 10,752
  • 11
  • 79
  • 78
1

I had same message when building signed apk. I thought my password was correct and there is problem with the .jks file. But I was entering wrong password

Then I tried another possible password it simply worked.

Note: Android studio doesn't block you when you enter wrong password multiple times. so try another possible password.

Or if you forgot the password try searching for password in log files

Go to => Help => Show Log in Explorer [If you haven't updated your android studio in between]

Or Go to => .gradle => 5.4.1(may differ) => executionHistory => executionHistory.bin and search for storePassword

Makarand
  • 623
  • 4
  • 16
0

For my case (using Android Studio), I found the Keystore file can't be delete, and it seems locked by OpenJDK. I suspect there should be something wrong between OpenJDK and Windows10's firewall. I close firewall temporarily. And it works.

0

Recently while signing an external apk with keytool I accidentally tampered with debug.keystore in C:\Users\myuser\.android so what I did is just backup previous debug.keystore and debug.keystore.lock this two file and deleted it. Then rebuild the project and it generates a new debug.keystore and debug.keystore.lock file. That's how I fixed my one.

Summary

  1. backup previous debug.keystore and debug.keystore.lock
  2. Delete it from C:\Users\myuser\.android
  3. Rebuild the project
Atik Rahman
  • 69
  • 12
0

I have been struggling also with the same problem.

I was sure of my password but the password was the problem.

As mentionned in an earlier post I when to => .gradle => 5.4.1(may differ) => executionHistory => executionHistory.bin and search for storePassword

And I saw that my password was missing a letter for encoding reasons:

In executionHistory.bin the password was : ...z§s..... and in my keystore.properties the password was : ...z§.....

After correcting this It works fine.

Nathalie
  • 445
  • 3
  • 14
0

Same problem here. The closest I have been of solving it has been following the advise from @Makarand https://stackoverflow.com/a/59386198/3187095

In my case, I doubt the problem to be the pasword, as I have it remembered by Android Studio itself. Still, it doesn't work. I can't generate de APK or bundle in release mode. And get the same message as mentioned above. Some other reason has to be the one in this case.

I have found my password in the executionHistory.bin file. They are the expected ones, and both are the same. My only doubt is about a symbol that have right before them, between storePassword and the password itself: Ž

So, it could happen that you enter the correct passwords and still you get the same message. Don't know the reason though.

0

I am facing the same issue and tried the below-metioned steps are fixed now.

Step 1: Make sure your keystore file name and key alias name.

Note: Keystore & alias password to be the same.

a) In android studio Build >> generate signed bundled Apk/.. Choose APK >> Next

enter image description here

Make sure all the fields remembered that we are going to mention in build.gradle & Gradle.properties

b) Project source android >> app >> Debug/Release keystore

enter image description here

Step 2: configure your kestore in Build.gradle

Open android >> app >> build.gradle

Under the android >> signinConfigs make sure all are right based on Debug or Release key

enter image description here

Step 3: Configure Keystore in gradle.propertie

Open android >> gradle.properties

Check Below mentioned If not You can Add it along with your kestore file. enter image description here

I hope It will help some.

Elavarasan r
  • 183
  • 12
-1

In my case I forgot to chanche build target from espresso test to app:

Slava Glushenkov
  • 1,101
  • 6
  • 9
-2

sometimes debug mode you don't need type the password, just press enter, when the prompt ask for password :)