失败:构建失败并出现异常。
- 什么地方出了错:
任务“:app:signReleaseBundle”执行失败。
执行 com.android.build.gradle.internal.tasks.FinalizeBundleTask$BundleToolRunnable 时发生故障
java.lang.NullPointerException(无错误消息)
24 秒内构建失败
运行 Gradle 任务“bundleRelease”... 26.2s
Gradle 任务bundleRelease 失败,退出代码为 1
Build.gradle 文件:-
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 32
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "co.demo.flutter"
minSdkVersion 21
multiDexEnabled true
targetSdkVersion 32
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
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
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// implementation 'com.android.support:multidex:2.0.1'
implementation 'com.google.android.gms:play-services-tagmanager:17.0.0'
implementation "androidx.multidex:multidex:2.0.1"
}
我遇到了同样的错误。
就我而言, key.properties 丢失了。
我刚刚将其添加到 [project]/android/key.properties 中
key.properties 的内容是;
storePassword=<password from previous step> (example: 12345678)
keyPassword=<password from previous step> (example: 12345678)
keyAlias=upload
storeFile=/Users/<user name>/upload-keystore.jks (Complete path of upload-keystore.jks
using "/" not "\")
之后,我运行此命令来构建应用程序包;
flutter build appbundle
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)