@@ -2,7 +2,7 @@ group = "io.livekit.plugin"
22version = " 1.0-SNAPSHOT"
33
44buildscript {
5- ext. kotlin_version = " 1.8.22 "
5+ ext. kotlin_version = " 2.1.0 "
66 repositories {
77 google()
88 mavenCentral()
@@ -22,7 +22,18 @@ allprojects {
2222}
2323
2424apply plugin : " com.android.library"
25- apply plugin : " kotlin-android"
25+
26+ // AGP 9's built-in Kotlin compiles Kotlin itself and rejects the Kotlin Gradle
27+ // Plugin. Apply KGP only when built-in Kotlin is NOT active: that means AGP < 9,
28+ // or AGP 9 with android.builtInKotlin=false (the configuration Flutter currently
29+ // ships by default while the ecosystem migrates).
30+ def agpMajor = com.android.Version . ANDROID_GRADLE_PLUGIN_VERSION . tokenize(" ." )[0 ] as int
31+ def builtInKotlinActive = agpMajor >= 9 &&
32+ (! project. hasProperty(" android.builtInKotlin" ) ||
33+ Boolean . parseBoolean(project. property(" android.builtInKotlin" ). toString()))
34+ if (! builtInKotlinActive) {
35+ apply plugin : " kotlin-android"
36+ }
2637
2738android {
2839 if (project. android. hasProperty(" namespace" )) {
@@ -36,10 +47,6 @@ android {
3647 targetCompatibility = JavaVersion . VERSION_1_8
3748 }
3849
39- kotlinOptions {
40- jvmTarget = JavaVersion . VERSION_1_8
41- }
42-
4350 sourceSets {
4451 main. java. srcDirs + = " src/main/kotlin"
4552 test. java. srcDirs + = " src/test/kotlin"
@@ -68,3 +75,19 @@ android {
6875 }
6976 }
7077}
78+
79+ // Configure the Kotlin JVM target. The compilerOptions DSL requires KGP 1.9+ or
80+ // AGP 9 built-in Kotlin; older Flutter app templates ship KGP 1.8.x, which only
81+ // supports the legacy kotlinOptions DSL.
82+ def kotlinExt = project. extensions. findByName(" kotlin" )
83+ if (kotlinExt?. hasProperty(" compilerOptions" )) {
84+ kotlin {
85+ compilerOptions {
86+ jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget . JVM_1_8
87+ }
88+ }
89+ } else {
90+ android. kotlinOptions {
91+ jvmTarget = JavaVersion . VERSION_1_8 . toString()
92+ }
93+ }
0 commit comments