plugins { id("com.android.application") id("kotlin-android") // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id("dev.flutter.flutter-gradle-plugin") } android { namespace = "com.cusotmer.im.im_app" compileSdk = flutter.compileSdkVersion ndkVersion = flutter.ndkVersion compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 isCoreLibraryDesugaringEnabled = true } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId = "com.cusotmer.im.im_app" // 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 ndk { // 只支持 arm64-v8a,减少包体积(现代 Android 设备均为 64-bit) abiFilters += "arm64-v8a" } } packaging { jniLibs { // 排除其他架构的 .so,防止第三方库把 armeabi-v7a / x86 带进包 excludes += setOf( "lib/armeabi-v7a/**", "lib/x86/**", "lib/x86_64/**", ) } } 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.getByName("debug") // R8 代码压缩:移除未使用的 Java/Kotlin 代码(来自依赖库) isMinifyEnabled = true // 资源压缩:移除未引用的 drawable / layout / string isShrinkResources = true proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro", ) } } } flutter { source = "../.." } kotlin { compilerOptions { jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17) } } dependencies { coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5") }