plugins { id "com.android.application" id "kotlin-android" id "dev.flutter.flutter-gradle-plugin" } def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' } def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' } // ── release 签名(key.properties 不入库,由本地或 CI 生成)──────────────── // 缺失时回退 debug 签名,保证本地 `flutter run --release`/无密钥环境仍可构建。 // CI 侧由 scripts/ci/compile-android.sh 落盘:client/android/key.properties // (storeFile/storePassword/keyAlias/keyPassword)。 def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') def hasReleaseSigning = keystorePropertiesFile.exists() if (hasReleaseSigning) { keystorePropertiesFile.withReader('UTF-8') { reader -> keystoreProperties.load(reader) } } android { namespace "com.pangolin.pangolin_vpn" compileSdkVersion flutter.compileSdkVersion ndkVersion flutter.ndkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' } sourceSets { main.java.srcDirs += 'src/main/kotlin' } defaultConfig { applicationId "com.pangolin.pangolin_vpn" // libbox requires minSdk 21 (gomobile -androidapi 21) minSdkVersion Math.max(flutter.minSdkVersion as Integer, 21) targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName } signingConfigs { if (hasReleaseSigning) { release { storeFile file(keystoreProperties['storeFile']) storePassword keystoreProperties['storePassword'] keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] } } } buildTypes { release { signingConfig hasReleaseSigning ? signingConfigs.release : signingConfigs.debug } } } flutter { source '../..' } // url_launcher(6.3.x)的 android 实现拉入 androidx.core:1.17 / androidx.browser:1.9, // 二者要求 AGP 8.9.1+,而本项目工具链是 AGP 8.6.0(升级 AGP 会牵动 libbox 原生构建,风险大)。 // 打开 URL 用不到这些新版 API → 强制降到兼容 AGP 8.6 的版本,构建通过、功能不受影响。 configurations.all { resolutionStrategy { force 'androidx.core:core:1.13.1' force 'androidx.core:core-ktx:1.13.1' force 'androidx.browser:browser:1.8.0' } } dependencies { // ── sing-box libbox(gomobile AAR)────────────────────────────── // 产物(gitignore,清掉/换 worktree 都要重建)二选一,均产 io.nekohasekai.libbox 包: // bash scripts/build-libbox.sh android # 官方 build_libbox,需 NDK ≥ 28(自动部署到此路径) // cd app/kernel && ./build-android.sh # 裸 gomobile bind,精简 tag、NDK 27 可 // ⚠️ 包名必须是 io.nekohasekai.libbox(Kotlin import 依赖);若编出默认 `libbox` 包, // 多半是 build-android.sh 漏了 -javapkg io.nekohasekai。 // 路径:client/android/app → ../../.. → repo root → app/kernel/dist/android/ // Kotlin stdlib 由 kotlin-android 插件自动引入,无需显式声明。 def libboxAar = file("${projectDir}/../../../app/kernel/dist/android/libbox.aar") if (libboxAar.exists()) { implementation files(libboxAar) } else { logger.warn("⚠ libbox.aar not found at ${libboxAar.absolutePath}") logger.warn(" Run: cd app/kernel && ./build-android.sh") } }