Flutter – Receiving error when using command "flutter build appbundle" – A failure occurred while executing com.android.build.gradle.internal.tasks

huangapple go评论71阅读模式
英文:

Flutter - Receiving error when using command "flutter build appbundle" - A failure occurred while executing com.android.build.gradle.internal.tasks

问题

我已按照此文档的所有步骤进行操作:https://docs.flutter.dev/deployment/android#signing-the-app

在运行命令时:flutter build appbundle

我收到以下错误信息:

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(没有错误消息)

之前,我尝试发布一个应用程序包到Google Play商店,但收到消息说我的SHA-1密钥不正确。为了解决这个问题,我点击了“更改应用程序签名密钥”。

现在它说:“Google将为您的发布生成并保护应用程序签名密钥”。我不确定这是否是我现在收到此错误的原因。如果需要更多详细信息,可以提供,感谢任何帮助!

英文:

I've followed all steps in this documentation: https://docs.flutter.dev/deployment/android#signing-the-app

When using command: flutter build appbundle

I'm receiving this error:

>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)


I previously tried to publish an app bundle to the Google Play Store but received a message that my SHA-1 key was incorrect. To fix this, I've clicked on "Change app signing key".

Now it says: "Google will generate and protect an app signing key for your releases". I'm not sure if this is why I'm receiving this error now. More details can be given if needed, thank you for any help!

答案1

得分: 1

解决了我的问题,在应用程序 -> build.gradle 文件 -> signingConfigs

我在 signingConfigs 内部声明了密钥属性,但你只需要将文档中显示的代码复制粘贴即可。

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

只需要在 key.properties 文件中输入密钥库属性。

英文:

Solved my problem, in app -> build.gradle file -> signingConfigs

I was declaring the key properties inside the signingConfigs when all you you have to do is copy + paste the actual code as it is shown in the documentation.

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

It is only in the key.properties file that you need to enter your keystore properties.

答案2

得分: 0

以下是您要翻译的代码部分:

In my `android/app/build.gradle` file, I formally had this at the beginning of the file:

  def localProperties = new Properties()
  def localPropertiesFile = rootProject.file('local.properties')
  def keystoreProperties = new Properties()
  def keystorePropertiesFile = rootProject.file('key.properties')
  if (localPropertiesFile.exists()) {localPropertiesFile.withReader('UTF-8') {reader -> localProperties.load(reader)}}

The top has only one `if` statement for `localPropertiesFile` file. After adding for keystoreProperties like below:

  def localProperties = new Properties()
  def localPropertiesFile = rootProject.file('local.properties')
  def keystoreProperties = new Properties()
  def keystorePropertiesFile = rootProject.file('key.properties')
  if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(newFileInputStream(keystorePropertiesFile))
  }
  if (localPropertiesFile.exists()) {localPropertiesFile.withReader('UTF-8') {reader -> localProperties.load(reader)}}

everything worked fine.

Plus...
At the beneath where you have:

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

I changed/added a few implementastions, makoijg me have:

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.google.android.gms:play-services-ads:22.2.0"
implementation "androidx.multidex:multidex:2.0.1"
}
英文:

Simple!

In my android/app/build.gradle file, I formally had this at the beginning of the file:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (localPropertiesFile.exists()) {localPropertiesFile.withReader('UTF-8') {reader -> localProperties.load(reader)}}

The top has only one if statement for localPropertiesFile file. After adding for keystoreProperties like below:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(newFileInputStream(keystorePropertiesFile))}
if (localPropertiesFile.exists()) {localPropertiesFile.withReader('UTF-8') {reader -> localProperties.load(reader)}}

everything worked fine.
Plus...
At the beneath where you have:

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

I changed/added a few implementastions, makoijg me have:

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.google.android.gms:play-services-ads:22.2.0"
implementation "androidx.multidex:multidex:2.0.1"
}

huangapple
  • 本文由 发表于 2023年3月7日 02:05:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/75654327.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定