Skip to content

Bump AGP to 8.7.0; pin builtInKotlin=false for Flutter 3.44.x#62

Open
ubxty wants to merge 1 commit into
tjarvstrand:mainfrom
ubxty:migrate-to-built-in-kotlin
Open

Bump AGP to 8.7.0; pin builtInKotlin=false for Flutter 3.44.x#62
ubxty wants to merge 1 commit into
tjarvstrand:mainfrom
ubxty:migrate-to-built-in-kotlin

Conversation

@ubxty

@ubxty ubxty commented Jun 8, 2026

Copy link
Copy Markdown

Summary

  • Bumps the Android Gradle Plugin pinned in android/build.gradle's
    buildscript classpath from 7.3.0 to 8.7.0, matching the direction
    the wider Flutter plugin community is moving and lining up with the
    AGP versions the example app's settings.gradle.kts already declares.
  • Bumps the plugin's Kotlin Gradle Plugin classpath from 1.7.10 to
    2.0.21 so it matches the KGP 2.x toolchain the example app's
    settings.gradle.kts declares.
  • Pins android.builtInKotlin=false and android.newDsl=false in the
    example's gradle.properties. On Flutter 3.44.x the Flutter Gradle
    plugin's detectApplyingKotlinGradlePlugin still calls
    pluginManager.apply("kotlin-android") on plugin subprojects during
    configuration, and AGP 9.0+ rejects the legacy
    apply plugin: "kotlin-android" when builtInKotlin=true. Keeping
    the legacy apply path working is the recommended temporary bypass
    until the project's minimum Flutter version moves past 3.44.
  • Switches the example app's jvmTarget from JavaVersion.VERSION_11
    to the string "11", which the KGP 2.x kotlinOptions extension
    requires under the Kotlin DSL.
  • CHANGELOG entry under 5.1.1 explaining the rationale.

Why AGP 8.7.0 (and not 7.3.0 / 9.x)?

The apply plugin: 'com.android.library' line in the plugin's
android/build.gradle is resolved against the buildscript classpath
in that file, not the AGP version the consuming app declares. Keeping
that classpath pinned at 7.3.0 is a long-standing source of
NoSuchMethodError / com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
NPEs on AGP 8+ consumer projects. Bumping to 8.7.0 keeps the plugin
aligned with the AGP 8.7+ versions that modern Flutter apps (including
this example) already pin in their settings.gradle.kts.

Verification

$ export PATH="$HOME/fvm/versions/stable/bin:$HOME/local/bin:$PATH"
$ cd example && flutter build apk --debug
✓ Built build/app/outputs/flutter-apk/app-debug.apk

on Flutter 3.44.1, Dart 3.12.1, Gradle 9.4.1, AGP 9.2.0 (the
combination the example app's settings.gradle.kts pins).

Not done in this PR (intentional)

  • The example app's gradle.properties does not flip
    android.builtInKotlin to true. The full built-in Kotlin migration
    has to wait for the project's minimum Flutter version to move past
    3.44 (the Flutter 3.45+ Flutter Gradle plugin teaches
    detectApplyingKotlinGradlePlugin to skip plugin subprojects that
    set builtInKotlin=true themselves).
  • The plugin's apply plugin: 'kotlin-android' line and kotlinOptions
    block remain in place for the same reason. They will be removed in
    the follow-up PR that does the full migration.

Bumps the Android Gradle Plugin pinned in android/build.gradle's
buildscript classpath from 7.3.0 to 8.7.0, matching the direction the
wider Flutter plugin community is moving and lining up with the AGP
versions the example app's settings.gradle.kts already declares.

Also pins android.builtInKotlin=false and android.newDsl=false in the
example's gradle.properties. On Flutter 3.44.x the Flutter Gradle
plugin's detectApplyingKotlinGradlePlugin still calls
pluginManager.apply("kotlin-android") on plugin subprojects during
configuration, and AGP 9.0+ rejects the legacy apply plugin when
builtInKotlin=true. Keeping the legacy apply path working is the
recommended temporary bypass until the project's minimum Flutter
version moves past 3.44 and the Flutter Gradle plugin's built-in
Kotlin detection is updated to skip plugin subprojects.

Other tweaks required to make the build green on Flutter 3.44.1:
- Bumps kotlin_version from 1.7.10 to 2.0.21 so the KGP classpath
  matches the Kotlin 2.x toolchain the example app's
  settings.gradle.kts declares (1.7.10 fails to resolve on
  Kotlin 2.2.20 runtime).
- Switches the example's jvmTarget from JavaVersion.VERSION_11
  to the string "11", which the KGP 2.x kotlinOptions extension
  requires under the Kotlin DSL.

Verified: `cd example && flutter build apk --debug` produces
build/app/outputs/flutter-apk/app-debug.apk on Flutter 3.44.1.
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.

2 participants