Skip to content

fix(mobile): align Android AGP/Gradle/Kotlin with Flutter 3.41.7 (unbreak Android build)#1775

Open
AaronGoldsmith wants to merge 1 commit into
block:mainfrom
AaronGoldsmith:fix/android-build-agp-flutter-alignment
Open

fix(mobile): align Android AGP/Gradle/Kotlin with Flutter 3.41.7 (unbreak Android build)#1775
AaronGoldsmith wants to merge 1 commit into
block:mainfrom
AaronGoldsmith:fix/android-build-agp-flutter-alignment

Conversation

@AaronGoldsmith

Copy link
Copy Markdown
Contributor

What

Realigns the Android build's AGP / Gradle / Kotlin versions to the defaults that our pinned Flutter (3.41.7) actually supports:

Tool Before After
Android Gradle Plugin 9.2.1 8.11.1
Gradle 9.5.1 8.14
Kotlin 2.3.21 2.2.20

Three lines across settings.gradle.kts and gradle-wrapper.properties.

Why

The Android build has been broken on main since 2026-05-20. Two Renovate PRs bumped the Android toolchain a full major version ahead of what Flutter 3.41.7 supports:

Under AGP 9, flutter run fails in a chain of ways:

  1. kotlin-android plugin "no longer required since AGP 9.0" (built-in Kotlin).
  2. After removing it, the Flutter Gradle plugin throws NullPointerException because AGP 9 "only reads the new DSL."
  3. Even past that, third-party plugins that still apply kotlin-android (e.g. app_badge_plus) collide with built-in Kotlin: "Cannot add extension with name 'kotlin', as there is an extension already registered."

The chosen versions aren't arbitrary — they're the exact template defaults this Flutter ships, from flutter_tools/lib/src/android/gradle_utils.dart:

const templateDefaultGradleVersion = '8.14';
const templateAndroidGradlePluginVersion = '8.11.1';
const templateKotlinGradlePluginVersion = '2.2.20';

Testing

  • flutter run builds and launches on a physical device (Pixel 3a XL, Android with targetSdk 36) — previously it failed at assembleDebug.
  • just mobile-check passes (dart format + flutter analyze: no issues).

Notes / caveats

  • This reverts to AGP 8 to unbreak the build against the currently-pinned Flutter (3.41.7). Migrating the app and its plugins to AGP 9 is a larger, separate effort — happy to go that direction instead if maintainers prefer.
  • CI does not currently compile the Android target, so it would not detect AGP/Gradle compatibility regressions — which is why chore(deps): update gradle to v9 #672/chore(deps): update plugin com.android.application to v9 #674 sat broken for ~7 weeks. The mobile job (.github/workflows/ci.yml) runs flutter pub get, format check, flutter analyze, and flutter test, but no Android Gradle / assembleDebug build. Suggested follow-up: an Android assembleDebug smoke build in CI, and/or Renovate constraints holding AGP/Gradle back until Flutter supports those majors.

The Android build has been broken on main since 2026-05-20. Renovate
bumped the Android Gradle Plugin to v9 (block#674) and Gradle to v9 (block#672),
but the pinned Flutter version (3.41.7) does not support AGP 9. The
Flutter Gradle plugin fails to apply under AGP 9's new DSL, and third-
party plugins that still apply `kotlin-android` (e.g. app_badge_plus)
collide with AGP 9's built-in Kotlin.

Realign the three version pins to the defaults Flutter 3.41.7 ships in
its own project templates (flutter_tools/lib/src/android/gradle_utils.dart):

  - AGP:    9.2.1  -> 8.11.1
  - Gradle: 9.5.1  -> 8.14
  - Kotlin: 2.3.21 -> 2.2.20

With these, `flutter run` builds and launches on a physical device.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Aaron Goldsmith <aargoldsmith@gmail.com>
@AaronGoldsmith AaronGoldsmith requested a review from a team as a code owner July 12, 2026 21:16
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.

1 participant