fix(android): support AGP 9 built-in Kotlin - #986
Open
goaly-ai-bot wants to merge 1 commit into
Open
Conversation
AGP 9 removed android.kotlinOptions and fails the build when the Kotlin
Gradle Plugin is applied on top of its built-in Kotlin support. Apply the
plugin only for AGP 8 and move jvmTarget into the kotlin{} block, which
both toolchains understand.
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.
Problem
Android Gradle Plugin 9 ships Kotlin support built in and fails the build when a module applies the Kotlin Gradle Plugin on top of it. Any app on AGP 9 that depends on
google_api_headers(directly or transitively) cannot build:AGP 9 also removed
android.kotlinOptions.I hit this in an app that reaches
google_api_headerstransitively through a place-picker package, where it was the last remaining blocker for the AGP 9 upgrade.Change
android/build.gradle, compatible with both AGP 8 and AGP 9:kotlin-androidis applied only when AGP is older than 9, using the same guard the already-migrated plugins use (device_info_plus,share_plus,package_info_plus,wakelock_plus):kotlinOptions { jvmTarget }moves intokotlin { compilerOptions { jvmTarget } }.No version bumps, no Dart or Kotlin source changes, no behavior change.
Verified
With this patch applied through a path override in a Flutter 3.47.2 app:
flutter build apk --debugOKandroid.builtInKotlin=trueflutter build apk --debugOK,flutter build appbundle --releaseOKReference: Built-in Kotlin migration for plugin authors
Happy to adjust style or split it however you prefer.
🤖 Generated with Claude Code
https://claude.ai/code/session_018VxBdp58Dd1HeCZgwFiwkD