chore(android): support AGP 9 built-in Kotlin#1102
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the Flutter plugin’s Android Gradle configuration to be compatible with Android Gradle Plugin (AGP) 9’s built-in Kotlin support, avoiding the Kotlin Gradle Plugin application path that AGP 9 rejects, while keeping older AGP setups working.
Changes:
- Conditionally applies
kotlin-androidonly when the detected AGP major version is < 9. - Switches Kotlin JVM target configuration from
android.kotlinOptionsto thekotlin { compilerOptions { ... } }block. - Adds a
.changes/entry for release-note generation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| android/build.gradle | Applies Kotlin plugin conditionally based on AGP major version and updates Kotlin compiler options configuration. |
| .changes/agp9-built-in-kotlin | Adds a patch-level “fixed” changeset entry for AGP 9 Kotlin compatibility. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f02d248 to
ed2d682
Compare
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.
Summary
Migrates the Android plugin to AGP 9's built-in Kotlin while keeping older toolchains building (same pattern as flutter-webrtc/flutter-webrtc#2075):
android.builtInKotlin=false(the configuration Flutter currently ships by default while the ecosystem migrates). When AGP 9's built-in Kotlin is active it registers thekotlinextension itself and rejects KGP, so applying it is skipped.kotlin { compilerOptions {} }DSL when the extension supports it (KGP 1.9+ / AGP 9 built-in Kotlin), falling back to the legacykotlinOptionsDSL for apps still on KGP 1.8.x.Context
AGP 9 uses built-in Kotlin support and rejects Android plugins that still apply KGP directly. This follows the Flutter compatibility migration path instead of raising the minimum supported toolchain.
Verification
flutter build apk --debug) on the current stable toolchain (AGP 8.x + modern KGP path).