group 'com.fintasys.emoji_picker_flutter' version '1.0-SNAPSHOT' buildscript { ext.kotlin_version = '1.9.20' repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:8.2.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } rootProject.allprojects { repositories { google() mavenCentral() } } apply plugin: 'com.android.library' // Built-in Kotlin: AGP 9+ provides Kotlin, so only apply KGP on older AGP. // AGP 9 enables Built-in Kotlin by default, but Flutter's AGP 9 migrator writes // android.builtInKotlin=false into gradle.properties while apps/plugins transition, // which leaves nothing to apply the `kotlin {}` extension unless we fall back to KGP. def agpMajorVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger() def builtInKotlinDisabled = project.hasProperty('android.builtInKotlin') && project.property('android.builtInKotlin').toString() == 'false' def appliesLegacyKotlin = agpMajorVersion < 9 || builtInKotlinDisabled if (appliesLegacyKotlin) { apply plugin: 'kotlin-android' } android { if (project.android.hasProperty("namespace")) { namespace 'com.fintasys.emoji_picker_flutter' } compileSdk = 35 compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 } sourceSets { main.java.srcDirs += 'src/main/kotlin' } defaultConfig { minSdkVersion 21 } } // Configure the Kotlin JVM target to match compileOptions (Java 17). It is not // inherited from compileOptions automatically, so it must be set on both paths. // Legacy KGP (<2.0) exposes kotlinOptions; Built-in Kotlin (AGP 9+, KGP 2.0+) // exposes the compilerOptions DSL instead. if (appliesLegacyKotlin) { android.kotlinOptions { jvmTarget = JavaVersion.VERSION_17.toString() } } else { kotlin { compilerOptions { jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 } } } dependencies { if (appliesLegacyKotlin) { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } }