签署 Android Release Build 的问题无法从密钥库读取密钥" [英] Issue signing Android Release Build " Failed to read key from keystore"

查看:29
本文介绍了签署 Android Release Build 的问题无法从密钥库读取密钥"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 gradle (assembleRelease) 生成发行版 apk.

I'm using gradle (assembleRelease) to generate the release apk.

我已将密钥库文件保存在 project/app/filename.keystore 中(在应用程序内)

I have saved the keystore file in project/app/filename.keystore (Within the application)

我已经指定了与登录 gradle.properties 文件相关的详细信息

I have specified details related to signing in gradle.properties file

RELEASE_STORE_FILE=filename.keystore
RELEASE_STORE_PASSWORD=****
RELEASE_KEY_ALIAS=alias
RELEASE_KEY_PASSWORD=****

我的 build.gradle 文件有以下与签名相关的内容

My build.gradle file has the following related to signing

signingConfigs {
        release {

            storeFile file(RELEASE_STORE_FILE)
            storePassword RELEASE_STORE_PASSWORD
            keyAlias RELEASE_KEY_ALIAS
            keyPassword RELEASE_KEY_PASSWORD
        }
    }

我在下面的同一个gradle文件中指定了签名配置

I have specified signing configurations in the same gradle file as below

 buildTypes {
    release {
        signingConfig signingConfigs.release
    }
 }

但是,当我尝试创建发布版本时,我不断收到以下错误

However, when I'm trying to create the release build I keep getting following error

Error:Execution failed for task ':app:package<flavor>Release'.
> Failed to read key from keystore

我尝试了以下

  • 输入错误的密码以查看是否可以找到该文件.由于我认为可以找到该文件,所以给出了以下错误并带有正确的路径.

  • Giving a wrong password to see if the file can be found.Gives the following error with correct path there for I assume the file can be found.

无法从存储"读取密钥:密钥存储被篡改,或密码不正确

感谢您的意见!

推荐答案

我的问题是我输入了一个随机的 keyAlias.尝试使用 IDE(IntlliJ Idea 和 Android Studio:构建菜单 -> 生成已签名的 APK)对 apk 进行签名时,通过单击用于输入密钥别名的文本框旁边的椭圆按钮 (...),我找到了之前为密钥库设置的正确密钥别名.仔细检查您没有为密钥库输入一些临时随机密码和密钥别名,因为它们应该与您在创建密钥库时为密钥库设置的密码和密钥别名相同.

My problem was that I had entered a random keyAlias. When trying to sign the apk using the IDE (IntlliJ Idea and Android Studio: Build menu -> generate signed APK), by clicking the ellipse button (...) next to the textbox for entering key alias, I found the correct key alias that I had earlier set for my keystore. Double check that you are not entering some ad-hoc random password and keyAlias for your keystore as they should be identical to the password and key alias you set for your keystore when creating it.

如果您忘记了密码或密钥别名,恐怕您必须创建一个新的密钥库,因为没有这些您将无法读取您的密钥库.我建议将这两个属性(并附加您的密钥库文件)保存在 Lastpass 之类的密码管理器中,因为您将来需要它们.

If you have forgotten either the password or the key alias, I am afraid you have to create a new keystore as you cannot read your keystore without these. I suggest saving these two properties (and attaching your keystore file) in a password manager like Lastpass, as you need them in future.

这篇关于签署 Android Release Build 的问题无法从密钥库读取密钥"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆