Skip to content

Commit ce820e2

Browse files
committed
chore(android): support AGP 9 built-in Kotlin
1 parent 707792b commit ce820e2

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

android/build.gradle

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ allprojects {
2222
}
2323

2424
apply plugin: "com.android.library"
25-
apply plugin: "kotlin-android"
25+
26+
def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize(".")[0] as int
27+
if (agpMajor < 9) {
28+
apply plugin: "kotlin-android"
29+
}
2630

2731
android {
2832
if (project.android.hasProperty("namespace")) {
@@ -36,10 +40,6 @@ android {
3640
targetCompatibility = JavaVersion.VERSION_1_8
3741
}
3842

39-
kotlinOptions {
40-
jvmTarget = JavaVersion.VERSION_1_8
41-
}
42-
4343
sourceSets {
4444
main.java.srcDirs += "src/main/kotlin"
4545
test.java.srcDirs += "src/test/kotlin"
@@ -68,3 +68,9 @@ android {
6868
}
6969
}
7070
}
71+
72+
kotlin {
73+
compilerOptions {
74+
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
75+
}
76+
}

0 commit comments

Comments
 (0)