fix(package_info_plus): support AGP 9 / built-in Kotlin#3882
fix(package_info_plus): support AGP 9 / built-in Kotlin#3882manuel-goester-n41 wants to merge 1 commit into
Conversation
AGP 9 removes support for applying the Kotlin Gradle Plugin (KGP). The Android
module applies `kotlin-android` directly, so apps that depend on package_info_plus
fail to build under AGP 9, and Flutter 3.44+ already warns about it.
Apply KGP only when built-in Kotlin is inactive (AGP < 9, or
`android.builtInKotlin=false` — the Flutter transition default), and migrate the
deprecated `kotlinOptions` block to the `kotlin { compilerOptions { } }` DSL. The
example app is migrated to built-in Kotlin as well. No change to the SDK range,
compileSdk (uses flutter.compileSdkVersion), Kotlin version (2.2.0), or runtime.
Verified by building the example with Flutter 3.44.2 on AGP 8.12 (KGP applied),
AGP 9.0.1 + Gradle 9.1.0 with builtInKotlin=false (KGP applied via Flutter's
shim) and builtInKotlin=true (package_info_plus is KGP-free and configures
cleanly under built-in Kotlin).
Closes fluttercommunity#3881
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Thanks for your contribution, but I will handle this topic myself as there will be conflicting changes after merging #3858 |
@vbuberen Just following up on this. Do you plan to open PR for the built-in Kotlin compatibility changes, or would you like me to go with follow-up PR with the one already merged? Also, regarding the addition of: def builtInKotlin = providers.gradleProperty('android.builtInKotlin').map { it.toBoolean() }.orElse(agpMajor >= 9).get()I was looking into whether that extra logic is actually necessary. It turns out the Flutter team didn't use that workaround in their example app migration (flutter/packages#11806). This is because the new Flutter already detects a missing KGP declaration and automatically handles the injection under the hood via detectApplyingKotlinGradlePlugin (introduced in flutter/flutter#184227): if (!hasKgpPlugin) {
try {
pluginManager.apply("kotlin-android")
} ...
}Given that the SDK handles the fallback automatically, we should be perfectly safe without manually parsing the I tested by copying the code from this guide here https://docs.flutter.dev/release/breaking-changes/migrate-to-built-in-kotlin/for-plugin-authors#supporting-flutter-versions-earlier-than-3-44 using local environment and the KGP warning disappear. |
I will open PRs myself. You already did enough of good contributions recently. And thanks a lot for such detailed descriptions - it is helpful and saves a lot of time. |
|
Great, thanks too! I will continue working on removing the Gradle warnings across the remaining packages then. |
|
I just did a quick test using the latest releases of Maybe you can open a new issue with step-by-step instructions using the provided example app. This will help demonstrate reproducibility and ensure the issue isn't isolated to your specific project configuration. |
|
@evanrich The change follows the official documentation to support apps pre-3.44.x Flutter and I tend to trust the documentation more than whatever LLM threw out on the screenshot. As suggested by another person above - open a proper bug report with steps to reproduce if there is any actual bug. |

Summary
AGP 9 removes support for applying the Kotlin Gradle Plugin (KGP).
package_info_plus's Android module applieskotlin-androiddirectly, so apps that depend on it fail to build under AGP 9, and Flutter 3.44+ already emits a warning:This migrates
package_info_plusto Flutter's built-in Kotlin in a backwards-compatible way. Closes #3881.Changes
kotlin-androidonly when built-in Kotlin is not active, i.e. on AGP < 9 or whenandroid.builtInKotlin=false(the Flutter transition default, which Flutter still sets to false even on AGP 9). This keeps the plugin building on both the legacy-KGP and built-in-Kotlin paths.compilerOptionsDSL — replace the deprecatedkotlinOptions { jvmTarget }block withkotlin { compilerOptions { jvmTarget = … } }, which works under both KGP and built-in Kotlin.kotlin-androidremoved,compilerOptionsDSL).No change to the supported SDK range,
compileSdk(alreadyflutter.compileSdkVersion), the Kotlin version (already 2.2.0 — sufficient for built-in Kotlin on AGP 9), or runtime behavior. Build-configuration only; no public API change.Verification
Built the example app with Flutter 3.44.2 in each relevant configuration:
android.builtInKotlinfalsefalsetruepackage_info_plusis KGP-free and configures cleanly under built-in KotlinUnder built-in Kotlin the plugin no longer appears in Flutter's KGP warning.
Notes
android.builtInKotlin, so it automatically tracks whatever Kotlin mode the host app is in — no action required from existing consumers.CHANGELOG.mdedit is included; the changelog entry is derived from thefix(package_info_plus): …commit.