LifeMate — Personal, Family & Learning Companion
design/mobile-navigation-review
chore/phase1-repository-cleanup
deploy/stable-web-apk
deployment-static
design/mobile-accessibility-v2
design/mobile-navigation-review
docs/child-education-access-decision
docs/offline-data-rescue-options
docs/owner-guide-and-delivery-plan
docs/phase1-policy-options
docs/public-review-live-2026-10-15
feat/aparat-learning-library
feat/child-device-safety
feat/child-identity-schema
feat/flutter-mobile-navigation
feat/learning-content-operations
feat/local-signing-preflight
feat/online-family-stage0
feat/personal-encrypted-recovery
feat/private-planner-series-api
feat/public-review-page
feat/standalone-weekly-planner
feat/weekly-planner-android
final-feature-1/iran-family-school
fix/auth-abuse-expiry-safety
fix/auth-expiry-after-lock
fix/backend-request-safety
fix/lifeguide-bootstrap-naming-ci
fix/lifeguide-pages-qa-base-preflight
fix/lifeguide-qa-pages-env-deployment
fix/local-task-persistence
fix/managed-child-session-boundary
fix/personal-jalali-dates
fix/personal-notification-controls
fix/personal-upgrade-delivery-guard
fix/sms-approval-gates
fix/study-duration-display
infra/cloudflare-neon-migration
infra/lifeguide-cloudflare-qa
infra/lifeguide-github-pages-qa
infra/lifeguide-supabase-qa
main
phase-1/foundation-completion
phase-2/product-foundation-identity
phase-3/planner-school-family-core
phase-4/ai-learning-wellbeing
phase-5/hardening-observability-release
test/android-reminder-acceptance
test/personal-notification-settings
test/personal-recovery-acceptance
test/role-entry-apk
| 1 | import java.util.Base64 |
| 2 | import java.security.KeyStore |
| 3 | import java.security.cert.X509Certificate |
| 4 | import javax.naming.ldap.LdapName |
| 5 | |
| 6 | plugins { |
| 7 | id("com.android.application") |
| 8 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. |
| 9 | id("dev.flutter.flutter-gradle-plugin") |
| 10 | } |
| 11 | |
| 12 | val releaseRequested = gradle.startParameter.taskNames.any { it.contains("release", ignoreCase = true) } |
| 13 | val releaseEnvironment = listOf("LIFEGUIDE_KEYSTORE_PATH", "LIFEGUIDE_KEYSTORE_PASSWORD", "LIFEGUIDE_KEY_ALIAS", "LIFEGUIDE_KEY_PASSWORD") |
| 14 | val signingValues = releaseEnvironment.associateWith { System.getenv(it) } |
| 15 | if (releaseRequested) { |
| 16 | val missing = signingValues.filterValues { it.isNullOrBlank() }.keys |
| 17 | if (missing.isNotEmpty()) throw GradleException("Release signing requires environment variables: ${missing.joinToString()}") |
| 18 | val keyFile = file(signingValues.getValue("LIFEGUIDE_KEYSTORE_PATH")!!) |
| 19 | val releaseAlias = signingValues.getValue("LIFEGUIDE_KEY_ALIAS")!! |
| 20 | if (!keyFile.isFile || keyFile.name.equals("debug.keystore", ignoreCase = true) || releaseAlias.equals("androiddebugkey", ignoreCase = true)) { |
| 21 | throw GradleException("A real owner-supplied release keystore is required.") |
| 22 | } |
| 23 | val keyStore = try { |
| 24 | KeyStore.getInstance(keyFile, signingValues.getValue("LIFEGUIDE_KEYSTORE_PASSWORD")!!.toCharArray()) |
| 25 | } catch (_: Exception) { |
| 26 | throw GradleException("The owner-supplied release keystore could not be opened.") |
| 27 | } |
| 28 | val certificate = keyStore.getCertificate(releaseAlias) as? X509Certificate |
| 29 | if (!keyStore.isKeyEntry(releaseAlias) || certificate == null) { |
| 30 | throw GradleException("The release signing alias must contain a private key and certificate.") |
| 31 | } |
| 32 | if (LdapName(certificate.subjectX500Principal.name).rdns.any { it.type.equals("CN", ignoreCase = true) && it.value.toString().equals("Android Debug", ignoreCase = true) }) { |
| 33 | throw GradleException("Android debug certificates are forbidden for release signing.") |
| 34 | } |
| 35 | val defines = providers.gradleProperty("dart-defines").orNull.orEmpty().split(',').filter { it.isNotBlank() } |
| 36 | if (defines.any { String(Base64.getDecoder().decode(it)).startsWith("LIFEGUIDE_DEBUG_CA_BASE64=") && String(Base64.getDecoder().decode(it)).substringAfter('=').isNotEmpty() }) { |
| 37 | throw GradleException("Development CA input is forbidden in release builds.") |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | android { |
| 42 | namespace = "ir.lifeguide.app" |
| 43 | compileSdk = flutter.compileSdkVersion |
| 44 | ndkVersion = flutter.ndkVersion |
| 45 | |
| 46 | compileOptions { |
| 47 | sourceCompatibility = JavaVersion.VERSION_17 |
| 48 | targetCompatibility = JavaVersion.VERSION_17 |
| 49 | } |
| 50 | |
| 51 | defaultConfig { |
| 52 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). |
| 53 | applicationId = "ir.lifeguide.app" |
| 54 | // You can update the following values to match your application needs. |
| 55 | // For more information, see: https://flutter.dev/to/review-gradle-config. |
| 56 | minSdk = flutter.minSdkVersion |
| 57 | targetSdk = flutter.targetSdkVersion |
| 58 | // Uses the version code from pubspec.yaml. When using split APKs, 1000 * ABI_VERSION |
| 59 | // is added automatically by Flutter. (https://developer.android.com/studio/build/configure-apk-splits#configure-APK-versions) |
| 60 | // You can force using the value of versionCode by specifying the `-P force-version-code-ignoring-abi=true` |
| 61 | // flag during build. |
| 62 | versionCode = flutter.versionCode |
| 63 | versionName = flutter.versionName |
| 64 | } |
| 65 | |
| 66 | signingConfigs { |
| 67 | create("release") { |
| 68 | signingValues["LIFEGUIDE_KEYSTORE_PATH"]?.let { storeFile = file(it) } |
| 69 | storePassword = signingValues["LIFEGUIDE_KEYSTORE_PASSWORD"] |
| 70 | keyAlias = signingValues["LIFEGUIDE_KEY_ALIAS"] |
| 71 | keyPassword = signingValues["LIFEGUIDE_KEY_PASSWORD"] |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | buildTypes { |
| 76 | release { |
| 77 | signingConfig = signingConfigs.getByName("release") |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | kotlin { |
| 83 | compilerOptions { |
| 84 | jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | flutter { |
| 89 | source = "../.." |
| 90 | } |