找不到用于签名配置的密钥库 'release'

Keystore Not Found for Signing Config 'release'

我在 运行 在 Flutter 上执行此命令时遇到问题:flutter build appbundle --target-platform android-arm,android-arm64,android-x64 我需要 运行 才能执行 flutter build apk.

build.gradle

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.release
        }
    }

key.properties

storePassword=XXXX
keyPassword=XXXX
keyAlias=key
storeFile="C:/Users/User/Key/key.jks"

错误:

* What went wrong:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file 'D:\Projects\Flutter\iusefully\android\app\"C:\Users\User\Key\key.jks"' not found for signing config 'release'.

将您的关键位置 c 更改为 d 驱动器... c 驱动器

同时出现权限问题

终于找到答案了, 我的问题出在 key.properties 文件中。 出现问题是因为我用了storeFile="LOC" .jks 路径变量的声明不应该在 " " 中 引用.

错误: storeFile="C:/Users/User/Key/key.jks"

右:storeFile=C:/Users/User/Key/key.jks

此外,我将 key.jks 文件添加到 /app 文件夹。

对我来说,重命名文件很有帮助 {home}\.android\debug.keystore{home}\.android\debug.keystore.jks

这个解决方案对我有用... 遵循此说明

https://flutter.dev/docs/deployment/android#create-a-keystore

并且在 key.properties 中不要将值放在 "" 中 例如:

storePassword=454545
keyPassword=456565
keyAlias=upload
storeFile= C:/Users/{profile}/upload-keystore.jks

除了 t0m3r 的回答,当 运行 下面的命令在 windows 时:将 USER_NAME 更改为您的用户名

keytool -genkey -v -keystore c:\Users\USER_NAME\upload-keystore.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload