diff --git a/.changes/agp9-built-in-kotlin b/.changes/agp9-built-in-kotlin new file mode 100644 index 000000000..bb0857676 --- /dev/null +++ b/.changes/agp9-built-in-kotlin @@ -0,0 +1 @@ +patch type="fixed" "Android plugin compatibility with AGP 9 built-in Kotlin" diff --git a/android/build.gradle b/android/build.gradle index dbc0cb96b..de68b7832 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -22,7 +22,11 @@ allprojects { } apply plugin: "com.android.library" -apply plugin: "kotlin-android" + +def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize(".")[0] as int +if (agpMajor < 9) { + apply plugin: "kotlin-android" +} android { if (project.android.hasProperty("namespace")) { @@ -36,10 +40,6 @@ android { targetCompatibility = JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8 - } - sourceSets { main.java.srcDirs += "src/main/kotlin" test.java.srcDirs += "src/test/kotlin" @@ -68,3 +68,9 @@ android { } } } + +kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8 + } +}