在 Flutter 中:构建 appBundle 时出错 ->* 出了什么问题:任务 ':app:signReleaseBundle' 执行失败

问题描述 投票:0回答:2

我正在尝试构建 appBundle 以在 Google Play 上发布我的应用程序。

我有这个错误:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:signReleaseBundle'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.FinalizeBundleTask$BundleToolRunnable
   > java.lang.NullPointerException (no error message)

* 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
Running Gradle task 'bundleRelease'...                              5,7s
Gradle task bundleRelease failed with exit code 1

我创建一个密钥: enter image description here

文件 key.properties:

storePassword=myPassWord
keyPassword=myPassWord
keyAlias=upload
storeFile=./keys.jks

将其放在 android 之前

 def keystoreProperties = new Properties()
   def keystorePropertiesFile = rootProject.file('key.properties')
   if (keystorePropertiesFile.exists()) {
       keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
   }
and this inside the android:
signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }
    buildTypes {
       release {
           signingConfig signingConfigs.release
       }
   }

我遵循https://docs.flutter.dev/deployment/android, 不知道为什么我做错了...

我尝试使用谷歌,但没有成功。重新创建密钥,什么都没有。

android flutter build build.gradle
2个回答
1
投票

我更改了文件以直接放置数据:

   keyAlias "upload"
   keyPassword "myPassWord"
   storeFile file(<path to file>)
   storePassword "myPassWord"

它起作用了。我认为这不是最好的解决方案。


0
投票

就我而言,我在 android 中将文件命名为错误的

keystore.properties
,并从
key.properties
中选取值。更改名称解决了我的问题。

© www.soinside.com 2019 - 2024. All rights reserved.