import java.util.Properties import java.io.FileInputStream repositories { google() mavenCentral() flatDir { dirs(project(":qq_music").projectDir.resolve("libs")) // 添加这行 dirs(project(":device_jieli").projectDir.resolve("libs")) // 杰理 SDK 运行时 .aar } } 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 // Google Play 渠道排除高德地图 .so(尚未支持 16KB 页面对齐) val envFile = rootProject.file("../.env") if (envFile.exists()) { val channel = envFile.readLines() .firstOrNull { it.trim().startsWith("Channel=") } ?.substringAfter("=")?.trim() if (channel == "GLOBAL_GOOGLE") { excludes += setOf("**/libAMapSDK*.so") } } } } 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") // device_jieli 杰理 SDK 运行时依赖(.aar 在 device_jieli 模块只能 compileOnly, // host app 必须自己引入,否则 RCSPController 等类在运行时找不到 → scanFeature 不会被初始化) implementation(":jl_bluetooth_rcsp_V4.2.0_beta1_40255_20260324@aar") implementation(":jl_audio_v2_V1.0.0_9-release@aar") implementation(":jldecryption_v0.4-release@aar") // jl_audio_decode 已经被 ble_service 通过 com.jieli.audio:jl_audio_decode:2.1.0 引入,无需重复 } flutter { source = "../.." }