问题
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
(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??
回答1:
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.
回答2:
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!
回答3:
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
回答4:
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
回答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 :)
回答6:
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
回答7:
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.
回答8:
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.
回答9:
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.
回答10:
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
- backup previous
debug.keystore
anddebug.keystore.lock
- Delete it from
C:\Users\myuser\.android
- Rebuild the project
回答11:
In my case I forgot to chanche build target from espresso test to app:
回答12:
sometimes debug mode you don't need type the password, just press enter, when the prompt ask for password :)
来源:https://stackoverflow.com/questions/32987530/android-studio-keystore-was-tampered-with-or-password-was-incorrect