【问题标题】:Flutter release aab bundle so got NullPointerException error. (android App Bundle)Flutter 发布 aab 包,因此出现 NullPointerException 错误。 (安卓应用程序包)
【发布时间】:2022-12-16 06:51:41
【问题描述】:

失败:构建失败,出现异常。

  • 出了什么问题: 任务 ':app:signReleaseBundle' 执行失败。

执行 com.android.build.gradle.internal.tasks.FinalizeBundleTask$BundleToolRunnable 时发生故障 java.lang.NullPointerException(无错误信息)

  • 尝试: 使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获得完整的见解。

  • https://help.gradle.org获得更多帮助

24 秒内构建失败 运行 Gradle 任务“bundleRelease”... 26.2 秒 Gradle 任务 bundleRelease 失败,退出代码为 1

构建.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"

}

【问题讨论】:

    标签: flutter dart gradle release android-app-bundle


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-28
      • 2020-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多