import java.util.Properties import java.io.FileInputStream repositories { google() mavenCentral() flatDir { dirs(project(":spotify_sdk").projectDir.resolve("libs")) dirs(project(":qq_music").projectDir.resolve("libs")) // 添加这行 } } 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") id("com.google.gms.google-services")version "4.3.13" } val keystorePropertiesFile = rootProject.file("app/sign/voitrans.properties") val keystoreProperties =Properties().apply { load(FileInputStream(keystorePropertiesFile)) // 使用 Kotlin 扩展方法 } android { namespace = "com.saitong.voitrans" compileSdk = 36 ndkVersion = "28.0.13004108" compileOptions { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 // Enable core library desugaring isCoreLibraryDesugaringEnabled = true } kotlinOptions { jvmTarget = JavaVersion.VERSION_11.toString() } // 添加lint选项 lintOptions { isCheckReleaseBuilds = false } // 添加packaging配置,排除冲突文件 packaging { resources { excludes.add("META-INF/DEPENDENCIES") excludes.add("META-INF/LICENSE") excludes.add("META-INF/LICENSE.txt") excludes.add("META-INF/license.txt") excludes.add("META-INF/NOTICE") excludes.add("META-INF/NOTICE.txt") excludes.add("META-INF/notice.txt") excludes.add("META-INF/*.kotlin_module") } jniLibs { useLegacyPackaging = true } } defaultConfig { manifestPlaceholders.putAll( mapOf( "redirectSchemeName" to "spotify-sdk", "redirectHostName" to "auth", "applicationName" to "com.saitong.voitrans.MyApp" // 新增:声明自定义 Application ) ) // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId = "com.saitong.voitrans" // You can update the following values to match your application needs. // For more information, see: https://flutter.dev/to/review-gradle-config. minSdk = 26 // 更新为26以满足ble_service库的要求 targetSdk = 35 // 设置为 Android 15 (API 35),以满足应用市场要求 versionCode = flutter.versionCode // 对应构建号,自动同步flutter构建号 versionName = flutter.versionName // 对应版本号,自动同步flutter版本号 } signingConfigs { create("release") { keyAlias = keystoreProperties.getProperty("keyAlias") keyPassword = keystoreProperties.getProperty("keyPassword") storeFile = file(keystoreProperties.getProperty("storeFile")) storePassword = keystoreProperties.getProperty("storePassword") enableV1Signing = true enableV2Signing = true enableV3Signing = false enableV4Signing = false } getByName("debug") { // debug 使用与 release 相同的签名配置 keyAlias = keystoreProperties.getProperty("keyAlias") keyPassword = keystoreProperties.getProperty("keyPassword") storeFile = file(keystoreProperties.getProperty("storeFile")) storePassword = keystoreProperties.getProperty("storePassword") enableV1Signing = true enableV2Signing = true enableV3Signing = false enableV4Signing = false } } buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. isMinifyEnabled = false isShrinkResources = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) signingConfig = signingConfigs.getByName("release") // Release 版本只保留 arm64-v8a 和 armeabi-v7a(移除 x86/x86_64) ndk { abiFilters += listOf("armeabi-v7a", "arm64-v8a") } } debug { isMinifyEnabled = false isShrinkResources = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) signingConfig = signingConfigs.getByName("debug") // Debug 版本保留所有 ABI(包括 x86/x86_64,用于模拟器) ndk { abiFilters += listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64") } } } } dependencies { // 添加核心库反糖化 coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3") // 添加 CardView 依赖 implementation("androidx.cardview:cardview:1.0.0") } flutter { source = "../.." }