fix: apply kotlin-android when builtInKotlin=false on AGP 9+#102
Open
proninyaroslav wants to merge 1 commit into
Open
fix: apply kotlin-android when builtInKotlin=false on AGP 9+#102proninyaroslav wants to merge 1 commit into
proninyaroslav wants to merge 1 commit into
Conversation
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.
Problem
Build fails with
Could not find method kotlin()(build.gradle:58) when using:Flutter 3.44 introduced a migration phase where it automatically sets
android.builtInKotlin=falseingradle.properties(via the Flutter migrator tool). This flag disables AGP 9's built-in Kotlin support, so the project still relies on the explicitkotlin-androidplugin.However, the plugin's condition
if (agpMajor < 9)skips applyingkotlin-androidfor all AGP 9+ projects — including those wherebuiltInKotlin=falseis set. As a result, nobody compiles the plugin's Kotlin sources andFlutterLibphonenumberPluginclass cannot be found at link time.Fix
Condition: also apply
kotlin-androidwhenandroid.builtInKotlinis explicitly'false', even on AGP 9+:Guard: wrap the kotlin {} compiler-options block in plugins.withId() so it only executes when the Kotlin plugin is actually present (safe for both the old path and the built-in Kotlin path):
Reproduction
FAILURE … Could not find method kotlin() for arguments on build.gradle:58After this fix the build succeeds with only a deprecation warning
(expected until downstream projects fully migrate to built-in Kotlin).