// Author: fruit.com.cn plugins { id("com.android.application") // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id("dev.flutter.flutter-gradle-plugin") } android { namespace = "com.stormg.lumadrama" // permission_handler_android 14 的 AAR 元数据要求依赖方 compileSdk >= 37, // 固定为 37(比 Flutter 默认的 36 高一档,只影响编译期 API 可见性)。 compileSdk = 37 ndkVersion = flutter.ndkVersion compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId = "com.stormg.lumadrama" // You can update the following values to match your application needs. // For more information, see: https://flutter.dev/to/review-gradle-config. minSdk = flutter.minSdkVersion targetSdk = flutter.targetSdkVersion versionCode = flutter.versionCode versionName = flutter.versionName } buildTypes { release { // 生产包只保留 arm64-v8a 与 armeabi-v7a,避免插件带入 x86_64 原生库 ndk { abiFilters += listOf("arm64-v8a", "armeabi-v7a") } // R8 裁剪未使用的 Java/Kotlin 代码与资源,减小 dex 与 res。 isMinifyEnabled = true isShrinkResources = true proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro", ) // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig = signingConfigs.getByName("debug") } } } kotlin { compilerOptions { jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 } } // 生产包不允许出现 x86_64:部分插件 AAR 会带入少量 x86_64 原生库,这里显式剔除。 androidComponents { onVariants(selector().withBuildType("release")) { variant -> variant.packaging.jniLibs.excludes.add("lib/x86_64/**") // 原生库随 APK 压缩存储:下载体积明显小于解压后的体积,代价是安装时解压。 // 本包 90% 体积是 so,这一项对国内商店的 APK 分发影响最大。 variant.packaging.jniLibs.useLegacyPackaging = true } } flutter { source = "../.." }