Skip to content

Fix Android Gradle build for Java 25#1258

Open
hut8 wants to merge 1 commit intomainfrom
fix/android-gradle-java25-compat
Open

Fix Android Gradle build for Java 25#1258
hut8 wants to merge 1 commit intomainfrom
fix/android-gradle-java25-compat

Conversation

@hut8
Copy link
Copy Markdown
Owner

@hut8 hut8 commented Mar 17, 2026

Summary

  • Upgrade Gradle 8.9 → 9.1.0 (first version with full Java 25 support)
  • Upgrade AGP 8.7.3 → 9.0.1, Kotlin 2.1.0 → 2.2.10, KSP 2.1.0-1.0.29 → 2.2.10-2.0.2
  • Remove separate kotlin-android plugin (AGP 9 has built-in Kotlin)
  • Replace deprecated kotlinOptions with jvmToolchain(21) and bump compileSdk to 36
  • Add android.disallowKotlinSourceSets=false for KSP compatibility with AGP 9

Context

The build was failing with the cryptic error 25.0.2 because Gradle 8.9's embedded Kotlin compiler couldn't parse the Java 25 version string. GraalVM 25's jlink also has a missing jdk.internal.vm.ci module that breaks Android's JDK image transform, so a JDK 21 toolchain is used for compilation.

Test plan

  • ./gradlew assembleDebug builds successfully
  • Verify on CI

Gradle 8.9's embedded Kotlin compiler cannot parse Java 25 version
strings, and GraalVM 25's jlink is incompatible with Android's
core-for-system-modules.jar. Upgrade to Gradle 9.1.0 + AGP 9.0.1 +
Kotlin 2.2.10 and use JDK 21 toolchain for compilation.
Copilot AI review requested due to automatic review settings March 17, 2026 19:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Android build configuration to support building with Java 25 by upgrading the Gradle/Android toolchain and adjusting Kotlin/JVM settings.

Changes:

  • Upgrade Gradle wrapper to 9.1.0 and bump AGP/Kotlin/KSP versions via the version catalog.
  • Adjust Android module configuration: compileSdk bump and move from deprecated kotlinOptions to a JVM toolchain.
  • Add android.disallowKotlinSourceSets=false to maintain KSP compatibility with newer AGP.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
android/gradle/wrapper/gradle-wrapper.properties Bumps Gradle wrapper distribution to 9.1.0.
android/gradle/libs.versions.toml Updates AGP/Kotlin/KSP versions and modifies plugin entries.
android/gradle.properties Adds an Android Gradle property needed for KSP/AGP compatibility.
android/build.gradle.kts Updates the root plugin alias declarations.
android/app/build.gradle.kts Updates app module plugins and Android/Kotlin/JVM compilation configuration.

You can also share your feedback on Copilot code review. Take the survey.

@@ -1,13 +1,12 @@
plugins {
alias(libs.plugins.android.application)
@@ -42,6 +42,5 @@ play-services-location = { group = "com.google.android.gms", name = "play-servic

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
Comment thread android/build.gradle.kts
@@ -1,6 +1,5 @@
plugins {
alias(libs.plugins.android.application) apply false
Comment on lines 30 to 37
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

kotlinOptions {
jvmTarget = "17"
kotlin {
jvmToolchain(21)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants