首页 > 解决方案 > 生成 APK 时出现“无法恢复密钥”错误

问题描述

生成签名的 APK 时出现以下错误:

 Caused by: java.lang.RuntimeException: com.android.ide.common.signing.KeytoolException: Failed to read key key0 from store "/Users/zorgan/Desktop/keystore": Cannot recover key

 Caused by: java.security.UnrecoverableKeyException: Cannot recover key
        at sun.security.provider.KeyProtector.recover(KeyProtector.java:315)
        at sun.security.provider.JavaKeyStore.engineGetKey(JavaKeyStore.java:141)
        at sun.security.provider.JavaKeyStore$JKS.engineGetKey(JavaKeyStore.java:56)
        at java.security.KeyStoreSpi.engineGetEntry(KeyStoreSpi.java:473)
        at sun.security.provider.KeyStoreDelegator.engineGetEntry(KeyStoreDelegator.java:172)
        at sun.security.provider.JavaKeyStore$DualFormatJKS.engineGetEntry(JavaKeyStore.java:70)
        at java.security.KeyStore.getEntry(KeyStore.java:1521)
        at com.android.ide.common.signing.KeystoreHelper.getCertificateInfo(KeystoreHelper.java:191)
        ... 32 more

我检查了我的executionHistory.bin文件并确认 Keystore 密码和 Key 密码都是正确的,并且都是相同的密码:

在此处输入图像描述

signingConfig.keyAliasÖkey0ösigningConfig.keyPasswordí**mypassword**úsigningConfig.storePasswordí**mypassword**òsigningConfig

在此处输入图像描述

可能是什么问题呢?

标签: androidandroid-studioterminalapk

解决方案


与此处的许多答案相反,密钥库密码密钥密码都必须不同:

在此处输入图像描述

我的 Keystore 密码是正确的,但我不得不为我的 Key 密码(别名密码)尝试不同的密码。最终它奏效了。


推荐阅读