Research: Kotlin 2.4.0 for kernel-ai-assistant
Source: https://blog.jetbrains.com/kotlin/2026/06/kotlin-2-4-0-released/
Current version: Kotlin 2.2.21 → target 2.4.0
Cross-reference: #915 (AGP 9 + Gradle 9 upgrade)
Reviewed by: oracle (see #915 comment)
Corrections from Oracle Review
| Original claim |
Correction |
| KSP 2.4.0 not released is the primary blocker |
Wrong. KSP 2.3.0 decoupled versioning from Kotlin. KSP 2.3.9 can potentially work with Kotlin 2.4.0. Real blocker is AGP: KSP 2.3.9's Gradle plugin needs AGP 9 API surfaces (NoSuchMethodError: AndroidComponentsExtension.addKspConfigurations on AGP 8.x). |
| AGP 8.7.3 satisfies Kotlin 2.4.0 minimum (8.5.2) |
Incomplete. Android's Kotlin support table requires AGP 9.1.0 for Kotlin 2.4. The KGP table (8.5.2) is the general JVM minimum, not the Android effective minimum. |
| Kotlin 2.4 follow-up is "just version bumps" |
Wrong. Must also: remove/revalidate -Xskip-metadata-version-check in 6 modules, ensure AGP 9 built-in Kotlin config is compatible, regression-test KSP/Hilt/Compose. There's a known open KSP regression (google/ksp#2964) with Hilt + Kotlin 2.4 module names. |
sourceSets deprecation flagged as relevant |
False positive. Repo uses android { sourceSets { } } (AGP API), not the deprecated KotlinAndroidProjectExtension.sourceSets. |
| AGP 9.2.1 is a safe target |
Risky. KGP 2.3.x supports AGP up to 9.0.0; KGP 2.4.0 supports AGP up to 9.1.0. AGP 9.2.x is outside both fully-supported matrices. Target AGP 9.1.1 instead. |
Actual Compatibility Assessment (corrected)
| Component |
Current |
Required for 2.4.0 |
Status |
| Kotlin |
2.2.21 |
2.4.0 |
— |
| AGP |
8.7.3 |
≥ 9.1.0 (Android effective minimum) |
🔴 Requires #915 first |
| KSP |
2.2.21-2.0.5 |
2.3.9 |
✅ (decoupled from Kotlin version) |
| Gradle |
8.11.1 |
7.6.3–9.5.0 (KGP 2.4.0) |
✅ (bump to 9.3.1 in #915) |
| Hilt |
2.58 |
2.59.2 |
⚠️ Needs #915 (Hilt 2.59 requires AGP 9) |
| JVM target |
17 |
any |
✅ |
| K1 |
not used |
removed in 2.4.0 |
✅ |
| Deprecated Compose flags |
not used |
→ ERROR in 2.4.0 |
✅ |
| AGP 9 built-in Kotlin |
N/A |
Must migrate |
🔴 #915 must handle |
Actual blocker chain: AGP 8.7.3 → must upgrade to AGP 9.1.x first (#915), which requires built-in Kotlin migration (removing org.jetbrains.kotlin.android from 14 modules, migrating kotlinOptions). Only then can Kotlin 2.4.0 be adopted, using KSP 2.3.9 (no need to wait for a KSP 2.4.0 release).
Known risk: google/ksp#2964 — open regression with Hilt code generation under Kotlin 2.4.0's new module-name behavior. Repo's @Provides methods are public (not internal), so the known trigger is not present, but this is an ecosystem risk to monitor.
Recommended Strategy (corrected)
| Step |
Issue |
Scope |
| 1 |
#915 |
AGP 9.1.1 + Gradle 9.3.1 + Kotlin 2.3.21 + KSP 2.3.9 + Hilt 2.59.2 + built-in Kotlin migration |
| 2 |
Follow-up PR |
Kotlin 2.3.21 → 2.4.0 on AGP 9.1.x baseline, remove -Xskip-metadata-version-check, verify KSP/Hilt/Compose |
Why not AGP 9.2.x: KGP 2.4.0's fully supported AGP window is 8.5.2–9.1.0. AGP 9.2.x requires Gradle 9.4.1 and is outside both KGP 2.3.x and 2.4.0 documented support.
Why not bundle Kotlin 2.4 into #915: AGP 9 built-in Kotlin migration alone touches 14 build scripts. Isolate that blast radius from the language upgrade.
Features (unchanged from original research)
Stable: context parameters, explicit backing fields, UUID API, .isSorted() checks, no deprecation warnings on imports, annotations in metadata by default, consistent intra-module inlining.
Experimental: collection literals, improved compile-time constants, returnsResultOf() contract, @IntroducedAt, map fallback functions.
Compose Compiler Changes
StrongSkipping, IntrinsicRemember → ERROR (not used). OptimizeNonSkippingGroups, PausableComposition → deprecated (not used).
- More consistent incremental compilation for
internal declarations. Possible artifact size increase from runtime stability inference for cross-file internal types (R8 can eliminate).
Performance Notes
- KSP 2.3.9 fixes a compilation perf regression from 2.3.8
- Hilt 2.59.2 fixes slow incremental-build regression from AGP 9 support
- Kotlin 2.4 Compose: better incremental compilation for
internal declarations
- Gradle daemon heap at
-Xmx4g should be sufficient; increase if AGP 9/KSP2 OOMs
Research: Kotlin 2.4.0 for kernel-ai-assistant
Source: https://blog.jetbrains.com/kotlin/2026/06/kotlin-2-4-0-released/
Current version: Kotlin 2.2.21 → target 2.4.0
Cross-reference: #915 (AGP 9 + Gradle 9 upgrade)
Reviewed by: oracle (see #915 comment)
Corrections from Oracle Review
NoSuchMethodError: AndroidComponentsExtension.addKspConfigurationson AGP 8.x).-Xskip-metadata-version-checkin 6 modules, ensure AGP 9 built-in Kotlin config is compatible, regression-test KSP/Hilt/Compose. There's a known open KSP regression (google/ksp#2964) with Hilt + Kotlin 2.4 module names.sourceSetsdeprecation flagged as relevantandroid { sourceSets { } }(AGP API), not the deprecatedKotlinAndroidProjectExtension.sourceSets.Actual Compatibility Assessment (corrected)
Actual blocker chain: AGP 8.7.3 → must upgrade to AGP 9.1.x first (#915), which requires built-in Kotlin migration (removing
org.jetbrains.kotlin.androidfrom 14 modules, migratingkotlinOptions). Only then can Kotlin 2.4.0 be adopted, using KSP 2.3.9 (no need to wait for a KSP 2.4.0 release).Known risk: google/ksp#2964 — open regression with Hilt code generation under Kotlin 2.4.0's new module-name behavior. Repo's
@Providesmethods are public (notinternal), so the known trigger is not present, but this is an ecosystem risk to monitor.Recommended Strategy (corrected)
-Xskip-metadata-version-check, verify KSP/Hilt/ComposeWhy not AGP 9.2.x: KGP 2.4.0's fully supported AGP window is 8.5.2–9.1.0. AGP 9.2.x requires Gradle 9.4.1 and is outside both KGP 2.3.x and 2.4.0 documented support.
Why not bundle Kotlin 2.4 into #915: AGP 9 built-in Kotlin migration alone touches 14 build scripts. Isolate that blast radius from the language upgrade.
Features (unchanged from original research)
Stable: context parameters, explicit backing fields, UUID API,
.isSorted()checks, no deprecation warnings on imports, annotations in metadata by default, consistent intra-module inlining.Experimental: collection literals, improved compile-time constants,
returnsResultOf()contract,@IntroducedAt, map fallback functions.Compose Compiler Changes
StrongSkipping,IntrinsicRemember→ ERROR (not used).OptimizeNonSkippingGroups,PausableComposition→ deprecated (not used).internaldeclarations. Possible artifact size increase from runtime stability inference for cross-fileinternaltypes (R8 can eliminate).Performance Notes
internaldeclarations-Xmx4gshould be sufficient; increase if AGP 9/KSP2 OOMs