Dart 颤振拾取错误的密钥库路径并给出错误key.jks未找到
我遵循了Flutter官方网站上的所有步骤,并认为我做的一切都是正确的,但在我构建密钥库文件时,它没有找到密钥库文件 这是我收到的错误消息,显示它选择了错误的路径,而不是Dart 颤振拾取错误的密钥库路径并给出错误key.jks未找到,dart,flutter,Dart,Flutter,我遵循了Flutter官方网站上的所有步骤,并认为我做的一切都是正确的,但在我构建密钥库文件时,它没有找到密钥库文件 这是我收到的错误消息,显示它选择了错误的路径,而不是 D:\apps\testapp\key.jks: PS D:\flutterapps\testapp> flutter build apk Initializing gradle... 1.3s Resolving dependencies...
D:\apps\testapp\key.jks
:
PS D:\flutterapps\testapp> flutter build apk
Initializing gradle... 1.3s
Resolving dependencies... 4.3s
Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file 'D:\flutterapps\testapp\android\app\ D: lutterappspublishkey.jks' not found for signing config 'release'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
Gradle task 'assembleRelease'... Done 5.3s
Gradle task assembleRelease failed with exit code 1
PS D:\flutterapps\testapp>
它在
build.gradle
中的任何位置调用。插入以下内容:
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
在你的android{}上面调用这个:
def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
并且key.properties文件(应该在您的根android文件夹中)应该有以下内容:
storePassword=12345
keyPassword=12345
keyAlias=key
storeFile=/Users/me/somekey.jks
使用修改的key.properties文件
storePassword=123456
keyPassword=123456
keyAlias=key
storeFile=key.jks
而不是这个
storePassword=123456
keyPassword=123456
keyAlias=key
storeFile=D:\flutterapps\testapp\key.jks
并将key.jks移动到
D:\apps\testapp\android\app\key.jks
如终端内部错误中显示的此路径
谢谢大家。在Windows上,您必须使用2个反斜杠来表示路径分隔。 在
key.properties
中,您应该有如下内容:
storeFile=D:\\flutterapps\\testapp\\key.jks
您不需要将
key.jks
文件复制到Flatter项目中。如果将错误的目录写入storefile,则在build.gradle中
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
这会将您的storefile放入文件(storefile),然后您会遇到这样一个丑陋的目录和错误
'D:\flutterapps\testapp\android\app\ D: lutterappspublishkey.jks'
是的,对我来说。。。我忘记在我的
build.gradle
文件中将我的signingConfig
更改为singingConfigs.release
buildTypes {
release {
//CHANGE THIS TO RELEASE
signingConfig signingConfigs.debug
}
}
你指的是官方网站上的哪些步骤?你的目录结构是什么?它似乎是在app文件夹中插入.jks文件,而不是父文件夹。他们把它戴上了./android/app。顺便问一下,您是如何设置登录密钥库的?用AS,手工在gradle文件中,或者什么?我在终端中设置了这个keytool-genkey-v-keystore D:\flatterapps\testapp\key.jks-keyalg RSA-keysize 2048-validity 10000-alias密钥的签名,它给出了成功的mesage,并在该路径中创建了key.jks文件。它考虑到它的路径是key.properties文件路径,而不是key.jkstorry,我已经提到过了按照这三个步骤进行操作,给出了一个奇怪的错误路径密钥库文件“D:\flutrapps\publish\android\app\D:lutterappspublishkey.jks”未找到用于签名配置“release”。您将什么设置为存储文件?我的密钥库文件名为key.jks,但它将某些内容作为密钥库文件“D:\flutrapps\testapp\android\app\(小于sign)D:lutterAppPublishKey.jks(大于符号)'未找到签名配置'release'。确定要调用key.properties文件吗?已保存我的一天。谢谢,这不是问题的原因。真正的原因在于windows的反斜杠。keytool认为这些是转义字符,只是忽略了它们。您可以使用此D:\\flutrapps\\testapp\\key.jks或此D:/flutrapps/testapp/key.jks来避免问题。如果要在应用程序中移动密钥(不推荐),请不要忘记在.gitignore文件中添加一行
key.jks
,因为此文件不应上载到任何公共存储库。您还需要\\而不是\如上所述。在windows中使用前向斜杠。解决方案是什么?