Skip to content

chore: support AGP 9's built-in Kotlin - #274

Open
TheoGermain wants to merge 3 commits into
mixpanel:mainfrom
TheoGermain:fix/agp9-built-in-kotlin
Open

chore: support AGP 9's built-in Kotlin#274
TheoGermain wants to merge 3 commits into
mixpanel:mainfrom
TheoGermain:fix/agp9-built-in-kotlin

Conversation

@TheoGermain

@TheoGermain TheoGermain commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

AGP 9 makes the org.jetbrains.kotlin.android plugin redundant and rejects it outright at build time:

Failed to apply plugin 'org.jetbrains.kotlin.android'
The 'org.jetbrains.kotlin.android' plugin is no longer required for Kotlin support since AGP 9.0.

This guards the plugin application behind an AGP-major-version check and moves jvmTarget/freeCompilerArgs to the compilerOptions DSL, which is understood both by the standalone kotlin-android plugin (AGP < 9) and by AGP 9's built-in Kotlin support (reference). Same pattern already shipped by device_info_plus, package_info_plus and share_plus for this exact migration.

Tested against a Flutter 3.47 / AGP 9.3.0 app — builds cleanly with this change, fails without it.

Fixes #260

AGP 9 makes the org.jetbrains.kotlin.android plugin's Kotlin support
redundant and rejects it outright:

  The 'org.jetbrains.kotlin.android' plugin is no longer required for
  Kotlin support since AGP 9.0.

Guard the plugin application behind an AGP-major-version check and
move the jvmTarget/freeCompilerArgs configuration to the compilerOptions
DSL, which works with both the standalone plugin (AGP < 9) and AGP 9's
built-in Kotlin support.
@TheoGermain
TheoGermain requested review from a team and rahul-mixpanel August 14, 2026 11:10
Same review feedback landed on tpucci/firebase_app_distribution#6 and
getsentry/sentry-dart#3970: android.builtInKotlin=false is the
documented way to opt back out of AGP 9's built-in Kotlin, so the guard
must check it, not just the AGP major version. Restores the original
kotlinOptions block (unaffected by JvmTarget enum version quirks) for
that path.
Verified against the actual kotlin-gradle-plugin-api-1.8.0 jar: JVM_17
(and JVM_1_8) are present since KGP 1.8.0, well below this module's own
pinned kotlin_version 1.9.0. The compilerOptions DSL split guarded
against a version mismatch that doesn't exist here; keep the single
unconditional block. android.builtInKotlin is still honored for the
plugin application.
@tylerjroach tylerjroach changed the title fix(android): support AGP 9's built-in Kotlin Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant