如果遵循Flutter中的指南,为什么会收到Gradle错误?

时间:2019-07-12 00:14:51

标签: android-studio flutter bundle

我试图从Flutter导出应用程序捆绑包,问题出在signingConfig上,默认是debug(它可以正常工作),但是如果我发布版本显示Gradle错误并且无法解决。如果遵循Flutter发行指南,该怎么办?或者我错了?

我已经创建了buildTypes,但是即使选择调试版本,仍然会出错。

android {
compileSdkVersion 29

lintOptions {
    disable 'InvalidPackage'
    checkReleaseBuilds false
}

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.homework.practice1"
    minSdkVersion 21
    targetSdkVersion 29
    ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}


signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile file(keystoreProperties['storeFile'])
        storePassword keystoreProperties['storePassword']
    }
}
buildTypes {
    release {
        signingConfig signingConfigs.release
    }
}

我希望导出32和64位应用程序捆绑包,但是当我进行调试签名时,它只是一个。如果选择释放会使Gradle错误1。

1 个答案:

答案 0 :(得分:0)

您可以在“ flutter”之后在build.gradle中添加此代码,如下所示,当您生成“ build”时,这将生成32位和64位应用程序,

flutter {
    source '../..'
}

afterEvaluate {
    mergeReleaseJniLibFolders.doLast {
        def archTypes = ["arm-release", "arm64-release"]
        archTypes.forEach { item ->
            copy {
                from zipTree("$flutterRoot/bin/cache/artifacts/engine/android-$item/flutter.jar")
                include 'lib/*/libflutter.so'
                into "$buildDir/intermediates/jniLibs/release/"
                eachFile {
                    it.path = it.path.replaceFirst("lib/", "")
                }
            }
        }
    }
}