Flutter选择错误的密钥库路径并给出错误的key.jks找不到

时间:2018-12-29 21:06:41

标签: dart flutter

我遵循了Flutter官方网站上的所有步骤,并认为我可以正确完成所有操作,但是在构建密钥库文件时找不到它。

这是我显示的错误消息,它使用错误的路径而不是 D:\flutterapps\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>

5 个答案:

答案 0 :(得分:3)

使用

修改的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:\ flutterapps \ testapp \ android \ app \ key.jks

此路径在终端内部显示为错误

谢谢。

答案 1 :(得分:1)

在Windows上,必须使用2个反斜杠来表示路径分隔。 在您的key.properties中,您应该有类似以下内容:

storeFile=D:\\flutterapps\\testapp\\key.jks

您不需要将key.jks文件复制到flutter项目中。

答案 2 :(得分:1)

是的,对我来说...我忘记将 signingConfig 文件中的 singingConfigs.release 更改为 build.gradle

    buildTypes {
        release {
           //CHANGE THIS TO RELEASE
            signingConfig signingConfigs.debug
        }
    }

答案 3 :(得分:0)

在您的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

答案 4 :(得分:0)

如果你将错误的目录写入 storefile 然后在 build.gradle;

storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null

这把你的storefile放到file(storefile)然后你遇到了这么丑的目录和错误

'D:\flutterapps\testapp\android\app\ D: lutterappspublishkey.jks'