Java Android Studio - 密钥库被篡改,或密码不正确

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32987530/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 14:07:21  来源:igfitidea点击:

Android Studio - Keystore was tampered with, or password was incorrect

javaandroidkeystoreandroid-keystore

提问by Lancelot

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

我正在尝试使用 Android Studio v1.4 中的内置小部件生成签名的 APK。

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

错误:任务 ':app:packageRelease' 的执行失败。无法从存储“C:\Users\Lancelot\Desktop\release.jks”读取密钥 cckey:密钥库被篡改,或密码不正确

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.

然后我输入了我的密钥密码,但在签署 APK 时没有运气......我什至尝试使用命令行更改密钥密码keytool -keypasswd -alias cckey -keystore C:\Users\Lancelot\Desktop\release.jks。通过运行这个我需要在输入新密码之前正确输入旧密码,这一切都通过了;这首先证明密钥密码没有错误。

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

那么问题来了,如果我的密钥库密码、密钥别名和密钥密码都正确,那有什么问题呢??

采纳答案by Lancelot

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

显然我刚刚发现几个月前发布的另一篇文章解决了我挣扎了好几天的问题......

Simply need to change the keystore and key alias password to be the samefor 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!

如果有人对此有答案,请让所有人知道!

回答by JPhi Denis

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

我刚刚遇到了同样的问题,我 100% 确定我的密码。我通过-storepass在命令行中添加直接找到了解决方案。使用此命令可以解决问题:

keytool -list -v -keystore C:\....\keystore.jks -storepass HereMyPassword -alias HereMyAlias

回答by Dinithe Pieris

how i solved the same problem with android studio 2.2.3

我是如何用 android studio 2.2.3 解决同样的问题的

Android studio >> file > project structure

Android Studio >> 文件 > 项目结构

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)

在左侧的模块下找到您的项目并选择它并单击签名选项卡。然后您可以通过单击绿色加号图标创建新配置,并使用现有密钥库密钥填写签名上的所有凭据。(确保您的“密钥 elias”、“密钥密码”和“存储密码”应该与以前使用的相同密钥存储相同,现在使用)

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 :)

快乐编码:)

回答by TechCrystal

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

显然 Google 决定将默认密钥库密码设置为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.

keytool 实用程序会提示您输入密钥库的密码。调试密钥库的默认密码是android。然后 keytool 将指纹打印到终端。

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

请参阅https://developers.google.com/android/guides/client-auth

回答by Jk33

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

回答by pableiros

My problem was I set the store password in the keyPasswordand the key password in the storePasswordand changing the passwords one by another the problem was solved.

我的问题是我在 中设置了商店密码,在 中设置了keyPassword密钥密码,storePassword并逐个更改了密码,问题解决了。

回答by Arnulfo B. Bataller

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 Buildthen Clean Project. This last resort worked for me.

我在更新我的应用程序时遇到了类似的问题。keytool 没有读取正确的密钥库文件,而是指向我几个月前创建但未使用的旧密钥库文件。在网上搜索了一些解决方案,但没有找到。几乎放弃了,但我想通过单击Build然后Clean Project清理项目。这最后的手段对我有用。

回答by user11087513

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.

对于我的情况(使用 Android Studio),我发现无法删除 Keystore 文件,并且它似乎被 OpenJDK 锁定。我怀疑 OpenJDK 和 Windows10 的防火墙之间应该有问题。我暂时关闭防火墙。它有效。

回答by Slava Glushenkov

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

就我而言,我忘记将构建目标从 espresso 测试更改为应用程序:

回答by Thomas Elliot

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.

就我而言,我从 Evernote 复制和粘贴密钥库和密钥密码,而 Android Studio 没有正确处理它。手动输入密码后,我能够生成 APK。