import java.util.Properties import java.io.FileInputStream import com.android.build.api.variant.FilterConfiguration.FilterType.* 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") } if (file("google-services.json").exists()) { apply(plugin = "com.google.gms.google-services") } dependencies { coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4") // For flutter_local_notifications // Workaround for: https://github.com/MaikuB/flutter_local_notifications/issues/2286 } // Workaround for https://pub.dev/packages/unifiedpush#the-build-fails-because-of-duplicate-classes configurations.all { // Use the latest version published: https://central.sonatype.com/artifact/com.google.crypto.tink/tink-android val tink = "com.google.crypto.tink:tink-android:1.17.0" // You can also use the library declaration catalog // val tink = libs.google.tink resolutionStrategy { force(tink) dependencySubstitution { substitute(module("com.google.crypto.tink:tink")).using(module(tink)) } } } android { namespace = "chat.fluffy.fluffychat" compileSdk = flutter.compileSdkVersion ndkVersion = "27.0.12077973" compileOptions { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 isCoreLibraryDesugaringEnabled = true } kotlinOptions { jvmTarget = JavaVersion.VERSION_11.toString() } signingConfigs { create("release") { keyAlias = "dummyAlias" keyPassword = "dummyPassword" storeFile = file("dummy.keystore") storePassword = "dummyStorePassword" } } val keystoreProperties = Properties() val keystorePropertiesFile = rootProject.file("key.properties") if (keystorePropertiesFile.exists()) { keystoreProperties.load(FileInputStream(keystorePropertiesFile)) signingConfigs.getByName("release").apply { keyAlias = keystoreProperties["keyAlias"] as String keyPassword = keystoreProperties["keyPassword"] as String storeFile = keystoreProperties["storeFile"]?.let { file(it) } storePassword = keystoreProperties["storePassword"] as String } } defaultConfig { applicationId = "chat.fluffy.fluffychat" minSdk = 21 targetSdk = flutter.targetSdkVersion versionCode = flutter.versionCode versionName = flutter.versionName } buildTypes { release { signingConfig = signingConfigs.getByName("release") proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") } } } flutter { source = "../.." } // From https://developer.android.com/build/configure-apk-splits#configure-APK-versions // // The following code creates a mapping that assigns a unique numeric value for each ABI // and overrides the output version code. val abiCodes = mapOf("x86_64" to 1, "armeabi-v7a" to 2, "arm64-v8a" to 3) androidComponents { onVariants { variant -> variant.outputs.forEach { output -> val name = output.filters.find { it.filterType == ABI }?.identifier val baseAbiCode = abiCodes[name] if (baseAbiCode != null) { output.versionCode.set(baseAbiCode + (output.versionCode.get() ?: 0) * 10) } } } }