Skip to content

fix(android): support AGP 9's built-in Kotlin - #6

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

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

Conversation

@TheoGermain

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, the same pattern already shipped by device_info_plus, package_info_plus and share_plus for this exact migration (reference).

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

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, same
pattern already shipped by device_info_plus, package_info_plus and
share_plus for this exact migration.
compileSdkVersion 30 is too old for several transitive androidx
dependencies (activity, arch-core, window.extensions.core), which now
require compiling against API 33/34+. AGP 9 turns this AAR metadata
mismatch into a hard build failure instead of a warning.
…piling

Same issue as reviewed on the sentry-dart / mixpanel-flutter equivalents:
- honor the android.builtInKotlin=false escape hatch, not just AGP major
  version.
- JvmTarget.JVM_1_8 requires KGP 1.9.0+, incompatible with this module's
  own pinned kotlin_version 1.5.20 on the AGP<9 path. Keep the original
  string-based kotlinOptions there.
TheoGermain added a commit to TheoGermain/mixpanel-flutter that referenced this pull request Aug 14, 2026
Same review feedback landed on HelloPrimary/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.
@tpucci

tpucci commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Merged into main via rebase (82b3f28) — verified on Flutter 3.47.5 / AGP 9.1 with built-in Kotlin enabled and with android.builtInKotlin=false. Thanks @TheoGermain! Released in the next patch version.

@tpucci tpucci closed this Oct 1, 2026
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