fix(android): build with AGP 9 and android.builtInKotlin=false (fixes #722) - #723
Closed
ened wants to merge 1 commit into
Closed
fix(android): build with AGP 9 and android.builtInKotlin=false (fixes #722)#723ened wants to merge 1 commit into
ened wants to merge 1 commit into
Conversation
The AGP 9 branch assumed built-in Kotlin is enabled. Flutter writes android.builtInKotlin=false by default (flutter/flutter#183910), so on AGP 9 the module applied neither KGP nor built-in Kotlin and evaluation failed with "Could not find method kotlin()". Condition KGP application on both axes, matching flutter_timezone 5.1.0: apply KGP when AGP < 9 or built-in Kotlin is disabled.
Collaborator
Author
|
Superseded by #721 from @EdwynZN — same root cause, same one-file fix, but his guard logic is better: it treats the flag as built-in-Kotlin-active unless explicitly Full local verification of the equivalent change: AGP 9.0.1 + |
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 #722 —
workmanager_androidfails to evaluate on AGP 9 whenandroid.builtInKotlin=false(Flutter's default, written by the Android migrator).Root cause
The AGP 9 handling from #710 branched on the AGP major version alone:
AGP 9 only provides the
kotlinextension whenandroid.builtInKotlin=true. With the flagfalse(whatflutter createwrites on Flutter 3.44+), neither KGP nor built-in Kotlin is active →Could not find method kotlin()at evaluation time. On the previous release (0.9.3) the same guard meant no Kotlin plugin was applied at all and the plugin class was missing at registration.Fix
Condition on both axes, the same pattern flutter_timezone 5.1.0 ships:
builtInKotlin=true: no KGP, built-in Kotlin provides thekotlinextension (unchanged behavior).builtInKotlin=false(Flutter default): KGP applied → extension present → module builds. This is the case that was broken.android.builtInKotlin=trueremains a valid app-level choice — no plugin change forces it.Verification (local, exact issue environment)
Standalone Gradle project with AGP 9.0.1 / KGP 2.3.20 / Gradle 9.2 /
android.newDsl=false+android.builtInKotlin=false, building the module directly:builtInKotlin=falseCould not find method kotlin()(reproduced, line 60)WorkmanagerPlugin/BackgroundWorkerbuiltInKotlin=trueRegression on the legacy path (example app, AGP 8.11):
:workmanager_android:testDebugUnitTest→ 50 tests, 0 failures.One file changed, 7+/7−, no behavior change for already-migrated projects.