import java.io.FileInputStream import java.util.Properties plugins { id("com.android.application") id("kotlin-android") id("com.google.gms.google-services") apply false // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id("dev.flutter.flutter-gradle-plugin") } val keystoreProperties = Properties() val keystorePropertiesFile = rootProject.file("key.properties") val hasKeystoreProperties = keystorePropertiesFile.exists() if (hasKeystoreProperties) { keystoreProperties.load(FileInputStream(keystorePropertiesFile)) } // B1: antes, sin key.properties el build "release" caía en silencio a la // firma de debug y terminaba con éxito — Play recién lo rechazaba al // subirlo ("signed in debug mode"). Cortar temprano, con mensaje claro, // apenas se detecta que se está compilando una variante Release. gradle.taskGraph.whenReady { val buildingRelease = allTasks.any { it.name.contains("Release") } if (buildingRelease && !hasKeystoreProperties) { throw GradleException( "Falta android/key.properties: no se puede compilar un release sin la " + "firma real. Nunca se firma un release con la clave de debug. " + "Ver docs/plan-lanzamiento.md (paso B1) para generar el keystore." ) } } android { namespace = "pe.sistemax.sysfarma" compileSdk = flutter.compileSdkVersion ndkVersion = flutter.ndkVersion compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { jvmTarget = JavaVersion.VERSION_17.toString() } defaultConfig { applicationId = "pe.sistemax.sysfarma" // 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 } signingConfigs { create("release") { keyAlias = keystoreProperties["keyAlias"] as String? keyPassword = keystoreProperties["keyPassword"] as String? storeFile = (keystoreProperties["storeFile"] as String?)?.let { file(it) } storePassword = keystoreProperties["storePassword"] as String? } } buildTypes { release { // Siempre la firma real. Si falta key.properties, el check de // arriba corta el build antes de llegar a firmar con esto. signingConfig = signingConfigs.getByName("release") } } } flutter { source = "../.." } if (file("google-services.json").exists()) { apply(plugin = "com.google.gms.google-services") }