fix: migrate Android plugin to built-in Kotlin (AGP 9) - #409
Open
Cherubins-App wants to merge 1 commit into
Open
Cherubins-App wants to merge 1 commit into
Cherubins-App wants to merge 1 commit into
Conversation
Stop applying kotlin-android and move Kotlin compiler options to the top-level compilerOptions block, following Flutter's migration guide for plugin authors. Raise the Flutter floor to 3.44, the first version that applies KGP to plugins on AGP < 9.
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.
Fixes #343. Supersedes the #344 spike, which predates the Compose plugin added for the inbox and now conflicts with
main.Changes
Following Flutter's migration guide for plugin authors:
kotlin-android. With AGP 9+, Kotlin is built into AGP. With AGP < 9 (orandroid.builtInKotlin=false), Flutter ≥ 3.44 applies it to the plugin.android.kotlinOptionsand the per-taskkotlinOptionswith the top-levelkotlin { compilerOptions { … } }block. Opt-ins now useoptIninstead of the deprecated-Xopt-in.>=3.44.0, as the guide requires. CI already uses 3.44.8. The Dartsdkconstraint is unchanged, so the package's language version does not change.About the Flutter floor
Projects on Flutter < 3.44 are not broken: pub keeps them on 4.5.0. In practice, 4.5.0 already needs a recent AGP 8 (
compileSdk 36, Java 17, KGP 2.1, Compose), so the current>=2.5.0floor is no longer accurate.If you'd rather keep the floor for a transitional release, there is an alternative. It builds under the same setups listed below, and I'm happy to switch the PR to it:
It only postpones the migration, though. Flutter detects KGP usage by matching
apply plugin: 'kotlin-android'in the build file with a regex (FlutterPluginUtils.kt), even inside anif.customer_iowould stay in the "Future versions of Flutter will fail to build if your app uses plugins that apply KGP" warning, and the floor bump would be needed once that warning becomes an error.Verification
Flutter 3.47.4, run locally: fork PRs don't get the secrets used by the sample-app build workflow.
builtInKotlin=trueFailed to apply plugin 'org.jetbrains.kotlin.android'builtInKotlin=falseflutter createapp downgraded to AGP 8.11.1 / KGP 2.2.20 / Gradle 8.14.3:customer_io:testDebugUnitTestunder built-in Kotlinflutter pub publish --dry-runAfter the change, Flutter's KGP warning no longer lists
customer_io.The sample apps are left on AGP 8 with
builtInKotlin=false. Moving them to AGP 9 depends on their other plugins (the source of the #344 CI failures) and is better done separately.