import org.jetbrains.kotlin.konan.properties.Properties import java.io.FileInputStream plugins { id("com.android.application") id("kotlin-android") id("org.jetbrains.kotlin.plugin.compose") // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id("dev.flutter.flutter-gradle-plugin") } val keystorePropertiesFile: File = rootProject.file("key.properties") val keystoreProperties = Properties() if (keystorePropertiesFile.exists()) { keystoreProperties.load(FileInputStream(keystorePropertiesFile)) } android { namespace = "cc.narumi.chaldea" compileSdk = 37 ndkVersion = flutter.ndkVersion compileOptions { isCoreLibraryDesugaringEnabled = true sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } buildFeatures { compose = true viewBinding = true resValues = true } packaging { jniLibs.useLegacyPackaging = true } flavorDimensions += "app" productFlavors { create("github") { dimension = "app" isDefault = true } create("play") { dimension = "app" } create("fdroid") { dimension = "app" applicationIdSuffix = ".fdroid" } } defaultConfig { applicationId = "cc.narumi.chaldea" minSdk = 24 targetSdk = flutter.targetSdkVersion // Split APK builds add an ABI offset to the pubspec version code. // Pass -P force-version-code-ignoring-abi=true to retain the exact value. versionCode = flutter.versionCode versionName = flutter.versionName multiDexEnabled = true resValue("string", "app_name", "Chaldea") } signingConfigs { if (keystorePropertiesFile.exists()) { register("release") { keyAlias = keystoreProperties.getProperty("keyAlias") keyPassword = keystoreProperties.getProperty("keyPassword") storeFile = file(keystoreProperties.getProperty("storeFile")) storePassword = keystoreProperties.getProperty("storePassword") } } } buildTypes { all { signingConfig = signingConfigs.getByName("release") } release { ndk { debugSymbolLevel = "FULL" } // Pangle SDK compat: disable new resource shrinker to avoid // ShrinkProtoResourcesAction ParseError (AGP 8.0+ replacement for // the removed android.enableNewResourceShrinker=false gradle.properties flag) isShrinkResources = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) } // create("profile") { // applicationIdSuffix = ".profile" // resValue("string", "app_name", "Chaldea Profile") // } debug { applicationIdSuffix = ".debug" resValue("string", "app_name", "Chaldea Debug") } } lint { checkReleaseBuilds = false } } kotlin { compilerOptions { jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 } } afterEvaluate { // Fix command without flavor listOf("debug", "release", "profile").forEach { buildType -> val taskName = "assemble${buildType.replaceFirstChar { it.uppercase() }}" tasks.matching { it.name == taskName }.configureEach { doLast { // default flavor (github) APK path val sourceApk = layout.buildDirectory .file("outputs/apk/github/$buildType/app-github-$buildType.apk") .get().asFile if (sourceApk.exists()) { // copy to Flutter CLI required path val targetDir = layout.buildDirectory .dir("outputs/flutter-apk") .get().asFile targetDir.mkdirs() sourceApk.copyTo( target = File(targetDir, "app-$buildType.apk"), overwrite = true ) println("✅ Copied app-github-$buildType.apk → app-$buildType.apk") } } } } } flutter { source = "../.." } dependencies { coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4") implementation("androidx.glance:glance-appwidget:1.1.1") // OkHttp: required by Pangle/GroMore SDK for network requests // (see official docs: https://www.csjplatform.com/supportcenter/28659) implementation("com.squareup.okhttp3:okhttp:3.12.1") // JVM unit tests: real org.json replaces the android.jar stubs for // XapkCore manifest parsing tests testImplementation("junit:junit:4.13.2") testImplementation("org.json:json:20240303") }