Skip to content

Commit 8e6c24d

Browse files
committed
Migrate Android build to Gradle 9 / AGP 9.4.0
Flutter's tooling warns that support for Gradle 8.14.5, AGP 8.13.2 and Kotlin 2.3.0 will soon be dropped. Bump Gradle to 9.6.0 and AGP to 9.4.0 (both current stable). AGP 9 reads only its new declarative DSL by default, which the Flutter Gradle plugin does not support yet: it throws an NPE in getLegacyAndroidExtension against AGP 9 defaults (flutter/flutter#191703), and the Flutter-side migration is still open (flutter/flutter#180137). Flutter's own migrator tool works around this today by setting android.newDsl=false and android.builtInKotlin=false, keeping the existing legacy DSL and the explicit kotlin-android plugin - so this does the same rather than rewriting build.gradle to the new DSL and built-in Kotlin support prematurely. That follow-up migration should happen once the Flutter Gradle plugin itself supports AGP 9's new DSL. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014gbNnPCT7nUxeWAQDiTzGR
1 parent f5cf76b commit 8e6c24d

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎android/gradle.properties‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
22
android.useAndroidX=true
33
android.enableJetifier=true
4+
5+
# AGP 9 only reads its new declarative DSL by default, which the Flutter
6+
# Gradle plugin doesn't support yet (flutter/flutter#180137) and throws an
7+
# NPE against (flutter/flutter#191703). Stay on the legacy DSL and the
8+
# kotlin-android plugin, as Flutter's own migrator tool does, until the
9+
# Flutter Gradle plugin's own migration lands.
10+
android.newDsl=false
11+
android.builtInKotlin=false

‎android/gradle/wrapper/gradle-wrapper.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

‎android/settings.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pluginManagement {
1818

1919
plugins {
2020
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21-
id "com.android.application" version "8.13.2" apply false
21+
id "com.android.application" version "9.4.0" apply false
2222
id "org.jetbrains.kotlin.android" version "2.3.0" apply false
2323
}
2424

0 commit comments

Comments
 (0)