Skip to content

Fix "Could not find method kotlin()" on AGP 9 when built-in Kotlin is off#90

Merged
kinex merged 1 commit into
masterfrom
fix/agp9-kotlin-dsl
Jun 24, 2026
Merged

Fix "Could not find method kotlin()" on AGP 9 when built-in Kotlin is off#90
kinex merged 1 commit into
masterfrom
fix/agp9-kotlin-dsl

Conversation

@kinex

@kinex kinex commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix the Could not find method kotlin() build failure on AGP 9 when android.builtInKotlin=false (the Flutter template default). On AGP 9 the Kotlin Gradle Plugin is skipped, so the unconditional kotlin {} block had no provider.
  • Configure the kotlin {} DSL only when KGP is applied (plugins.withId("org.jetbrains.kotlin.android")), and apply kotlin-android whenever built-in Kotlin is off (agpMajor < 9 || !builtInKotlin).

Test plan

  • Reproduced the crash in a fresh Flutter 3.44 app (AGP 9.0.1, builtInKotlin=false); the fix builds cleanly.
  • Verified builtInKotlin=true (AGP 9) and AGP 8.11.1 both still build.

Fixes #86

… off

The kotlin {} DSL is only registered by the Kotlin Gradle Plugin. On AGP 9 with
android.builtInKotlin=false (the Flutter template default), KGP is skipped, so the
unconditional kotlin {} block failed with "Could not find method kotlin()".

- Configure kotlin {} only via plugins.withId("org.jetbrains.kotlin.android")
- Apply kotlin-android whenever built-in Kotlin is off (agpMajor < 9 || !builtInKotlin)

Fixes #86
Copilot AI review requested due to automatic review settings June 24, 2026 08:30
@kinex kinex merged commit 3f7fb9c into master Jun 24, 2026
1 check failed
@kinex kinex deleted the fix/agp9-kotlin-dsl branch June 24, 2026 08:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Package flags KGP warning on flutter 3.44

2 participants