Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased

- Support AGP 9 built-in Kotlin while retaining legacy KGP and Apple packaging support.

## 0.5.1

### 🔧 Bug Fixes
Expand Down
21 changes: 14 additions & 7 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ allprojects {
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
// AGP 9 provides Kotlin unless the host explicitly opts out.
def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int
def builtInKotlinEnabled = agpMajor >= 9 && providers.gradleProperty("android.builtInKotlin")
.map { it.toBoolean() }
.orElse(true)
.get()
if (!builtInKotlinEnabled) {
apply plugin: 'kotlin-android'
}

android {
// Conditional for compatibility with AGP <4.2.
Expand All @@ -40,12 +48,11 @@ android {
targetCompatibility JavaVersion.VERSION_11
}

kotlinOptions {
jvmTarget = '11'
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
// Built-in Kotlin inherits the Java target; legacy KGP needs this option.
if (!builtInKotlinEnabled) {
kotlinOptions {
jvmTarget = '11'
}
}

defaultConfig {
Expand Down