import java.util.Properties plugins { id("com.android.application") // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id("dev.flutter.flutter-gradle-plugin") } // Release signing key, kept out of the repo, shared with the other apps. // // This matters more here than elsewhere: a device owner can only be replaced // by an APK with the same signature, and `dpm remove-active-admin` does not // work on one. Provisioning a debug-signed build would mean the app could // never be updated, and the only exit from a stale device owner that cannot // release itself is another factory reset. val keystoreProperties = Properties().apply { val f = rootProject.file("key.properties") if (f.exists()) f.inputStream().use { load(it) } } android { namespace = "com.kuhy.focus_owner" compileSdk = flutter.compileSdkVersion ndkVersion = flutter.ndkVersion compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId = "com.kuhy.focus_owner" // 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 { if (keystoreProperties.getProperty("storeFile") != null) { create("release") { storeFile = file(keystoreProperties.getProperty("storeFile")) storePassword = keystoreProperties.getProperty("storePassword") keyAlias = keystoreProperties.getProperty("keyAlias") keyPassword = keystoreProperties.getProperty("keyPassword") } } } buildTypes { release { // Falls back to the debug key only when key.properties is absent // (a fresh clone), so `flutter run --release` still works. signingConfig = signingConfigs.findByName("release") ?: signingConfigs.getByName("debug") // Deliberately no minify/shrink. An untested ProGuard pass that // strips a DevicePolicyManager callback would produce a device // owner that cannot release itself, and that costs a factory // reset to undo. } } } kotlin { compilerOptions { jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 } } flutter { source = "../.." } dependencies { // org.json is an Android stub on the JVM classpath, so unit tests need a // real implementation to parse the policy asset. testImplementation("org.json:json:20240303") testImplementation("junit:junit:4.13.2") }