chore: support AGP 9's built-in Kotlin - #274
Open
TheoGermain wants to merge 3 commits into
Open
Conversation
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AGP 9 makes the
org.jetbrains.kotlin.androidplugin redundant and rejects it outright at build time:This guards the plugin application behind an AGP-major-version check and moves
jvmTarget/freeCompilerArgsto thecompilerOptionsDSL, which is understood both by the standalonekotlin-androidplugin (AGP < 9) and by AGP 9's built-in Kotlin support (reference). Same pattern already shipped bydevice_info_plus,package_info_plusandshare_plusfor this exact migration.Tested against a Flutter 3.47 / AGP 9.3.0 app — builds cleanly with this change, fails without it.
Fixes #260