Support AGP 9 built-in Kotlin - #367
Open
SLIPPECAT wants to merge 1 commit into
Open
Conversation
AGP 9 ships built-in Kotlin support and registers its own `kotlin { }`
extension. Unconditionally applying the classic 'kotlin-android' plugin
on top of it fails ("no longer required for Kotlin support since AGP 9"),
which currently blocks apps that adopt AGP 9 with built-in Kotlin enabled
from depending on this plugin.
Only apply 'kotlin-android' when it's actually needed: on AGP < 9, or on
AGP 9+ where the app has explicitly opted out via
`android.builtInKotlin=false` (Flutter's current recommended interim
state for AGP 9 adopters). Move the jvmTarget configuration to the
top-level `kotlin { compilerOptions { } }` block per Flutter's plugin
migration guide, since that extension is present in both cases.
Verified against a real Flutter app on AGP 9.0.1 / Gradle 9.1.0 with
`android.builtInKotlin=false` (today's supported "opt-out" combination)
— `flutter build appbundle --release` succeeds with this change, with
no change in output versus the current published version. The
`builtInKotlin=true` path (Flutter 3.47+) follows AGP's documented
built-in Kotlin behavior but wasn't independently build-tested since it
requires a newer Flutter SDK than what's available in the test app.
See https://docs.flutter.dev/release/breaking-changes/migrate-to-built-in-kotlin/for-plugin-authors
Author
|
Friendly bump on this — Flutter 3.47.2 (stable) is out now, which is the SDK version needed to actually build-test the |
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
Android Gradle Plugin 9.0 ships built-in Kotlin support and registers its own
kotlin { }extension. Unconditionally applyingapply plugin: 'kotlin-android'on top of it now fails with:This currently blocks any app that has adopted AGP 9 with built-in Kotlin enabled (the default once on AGP 9, unless the app opts out) from depending on
flutter_naver_map. Flutter's own build now flags this plugin explicitly:Fix
Per Flutter's Built-in Kotlin migration guide for plugin authors:
'kotlin-android'when it's actually needed: on AGP < 9, or on AGP 9+ where the consuming app has explicitly opted out viaandroid.builtInKotlin=falseingradle.properties(this is currently Flutter's recommended interim state for most AGP 9 adopters, since much of the plugin ecosystem hasn't migrated yet).jvmTargetconfiguration out of the deprecatedandroid { kotlinOptions { } }block into the top-levelkotlin { compilerOptions { } }block, since that extension is registered in both the classic-plugin and built-in-Kotlin cases.Testing
Verified against a real Flutter app (AGP 9.0.1, Gradle 9.1.0,
android.builtInKotlin=false— today's supported "opt-out" combination) via a local pathdependency_override:flutter build appbundle --releasesucceeds with this change, producing the same output as with the currently published version — no regression for existing users on this combination or on AGP < 9.The
android.builtInKotlin=truepath (requires Flutter 3.47+) follows AGP's documented built-in-Kotlin behavior, but I wasn't able to independently build-test it since it needs a newer Flutter SDK than what's available in my test app.Happy to adjust the approach if you'd prefer a different structure (e.g. matching the pattern used in flutter/packages' first-party plugins).