From 6fb2ff2b9cfe2e1e5496e88700669ebf3eda644f Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Thu, 21 May 2026 23:04:21 -0400 Subject: [PATCH] chore(android): bump Kotlin 2.2 -> 2.3 + KSP 2.0 -> 2.3 for AGP 9 built-in Kotlin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous attempt opted out of AGP 9's built-in Kotlin (via android.builtInKotlin=false + explicit kotlin-android plugin) because the message from Gradle suggested it. But Kotlin 2.2.21's kotlin-android plugin can't cast AGP 9's new ApplicationExtension to the removed BaseExtension: class ApplicationExtensionImpl$AgpDecorated_Decorated cannot be cast to class com.android.build.gradle.BaseExtension That suggestion is for projects with an older Kotlin toolchain. The real fix: - Kotlin 2.3.21 (latest stable; first line where kotlin-android also supports AGP 9, but more importantly the built-in path works) - KSP 2.3.8 — KSP PR #2674 (merged Oct 2025) added AGP 9 built-in Kotlin support. KSP 1.x and pre-2.3 don't work with built-in Kotlin. - Re-drop the kotlin-android plugin from both build.gradle.kts files; AGP 9 enables built-in Kotlin by default and KSP 2.3 cooperates. - Remove android.builtInKotlin=false from gradle.properties. compose-compiler plugin tracks the Kotlin version via version.ref, so no separate bump there. Co-Authored-By: Claude Opus 4.7 (1M context) --- android/app/build.gradle.kts | 8 ++++---- android/build.gradle.kts | 8 ++++---- android/gradle.properties | 6 ------ android/gradle/libs.versions.toml | 16 ++++++++++------ 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 5d5df87d..7df58cbb 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -1,9 +1,9 @@ plugins { alias(libs.plugins.android.application) - // kotlin-android applied explicitly: AGP 9's built-in Kotlin path is - // not compatible with KSP yet. Opted out via - // android.builtInKotlin=false in gradle.properties. - alias(libs.plugins.kotlin.android) + // kotlin-android NOT applied: AGP 9 enables built-in Kotlin by default, + // and KSP 2.3.x supports it (PR #2674, merged Oct 2025). serialization + // + compose-compiler are language-level Kotlin compiler plugins and + // still need explicit application. alias(libs.plugins.kotlin.serialization) alias(libs.plugins.compose.compiler) alias(libs.plugins.ksp) diff --git a/android/build.gradle.kts b/android/build.gradle.kts index b3c00232..b70485b0 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -1,9 +1,9 @@ plugins { alias(libs.plugins.android.application) apply false - // kotlin-android needed despite AGP 9's built-in Kotlin: KSP isn't - // compatible with the builtInKotlin path yet, so we opt out via - // android.builtInKotlin=false in gradle.properties. - alias(libs.plugins.kotlin.android) apply false + // kotlin-android NOT registered: AGP 9 built-in Kotlin + KSP 2.3.x + // covers the Kotlin compilation path. Language-level Kotlin compiler + // plugins (serialization, compose-compiler) are still applied + // explicitly per module. alias(libs.plugins.kotlin.serialization) apply false alias(libs.plugins.ksp) apply false alias(libs.plugins.hilt) apply false diff --git a/android/gradle.properties b/android/gradle.properties index 8e0266b4..b605a620 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -4,10 +4,4 @@ org.gradle.caching=true org.gradle.configuration-cache=true android.useAndroidX=true android.nonTransitiveRClass=true - -# KSP isn't compatible with AGP 9's built-in Kotlin support (the -# `android.builtInKotlin=true` default). Opt out so we can apply the -# explicit kotlin-android plugin and KSP together. Revisit when KSP -# adds built-in-Kotlin support. -android.builtInKotlin=false kotlin.code.style=official diff --git a/android/gradle/libs.versions.toml b/android/gradle/libs.versions.toml index 59a5ef12..871c64c0 100644 --- a/android/gradle/libs.versions.toml +++ b/android/gradle/libs.versions.toml @@ -1,11 +1,15 @@ [versions] -# Pinned for JDK 25 compat: Gradle 9.1.0 supports JDK 25, AGP 9.0.1 -# requires Gradle 9.1.0+, AGP 9.0 requires Kotlin Gradle Plugin 2.2.10+, -# KSP follows Kotlin version. See gradle-wrapper.properties for the -# Gradle version itself. +# Pinned for JDK 25 + AGP 9 + KSP-built-in-Kotlin compat: +# - Gradle 9.1.0 supports JDK 25 (see gradle-wrapper.properties) +# - AGP 9.0.1 requires Gradle 9.1.0+ +# - Kotlin 2.3.x: AGP 9's built-in Kotlin path; the older kotlin-android +# plugin can't cast AGP 9's ApplicationExtension to the removed +# BaseExtension, and KSP 1.x isn't compatible with built-in Kotlin +# - KSP 2.3.x (PR #2674, merged Oct 2025): adds AGP 9 built-in Kotlin +# support, so we don't need the kotlin-android plugin at all agp = "9.0.1" -kotlin = "2.2.21" -ksp = "2.2.21-2.0.5" +kotlin = "2.3.21" +ksp = "2.3.8" hilt = "2.59.2" hilt-androidx = "1.2.0" compose-bom = "2026.05.01"