import java.util.Properties import java.io.FileInputStream 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") } // 读取 release 签名配置(key.properties 不入库,由本地或 CI 生成)。 // 缺失时回退 debug 签名,保证本地 `flutter run --release` 与无密钥环境可用。 val keystoreProperties = Properties() val keystorePropertiesFile = rootProject.file("key.properties") val hasReleaseSigning = keystorePropertiesFile.exists() if (hasReleaseSigning) { keystoreProperties.load(FileInputStream(keystorePropertiesFile)) } android { namespace = "com.yanmei.jiu" compileSdk = flutter.compileSdkVersion ndkVersion = flutter.ndkVersion compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { jvmTarget = JavaVersion.VERSION_17.toString() } defaultConfig { applicationId = "com.yanmei.jiu" minSdk = flutter.minSdkVersion targetSdk = flutter.targetSdkVersion versionCode = flutter.versionCode versionName = flutter.versionName } signingConfigs { if (hasReleaseSigning) { create("release") { storeFile = file(keystoreProperties["storeFile"] as String) storePassword = keystoreProperties["storePassword"] as String keyAlias = keystoreProperties["keyAlias"] as String keyPassword = keystoreProperties["keyPassword"] as String } } } buildTypes { release { signingConfig = if (hasReleaseSigning) { signingConfigs.getByName("release") } else { // 无正式密钥时回退 debug,便于本地构建/调试 signingConfigs.getByName("debug") } } } } flutter { source = "../.." }