From 5e7cb8c5a99222a3870734d361839675eace1490 Mon Sep 17 00:00:00 2001 From: Guillaume Bernos Date: Tue, 28 Apr 2026 10:31:43 +0100 Subject: [PATCH 1/3] ci: add AGP9 compatibility checks in CI --- .github/workflows/android.yaml | 26 +++++++++++++++++++ .../workflows/scripts/agp9-compatibility.sh | 26 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 .github/workflows/scripts/agp9-compatibility.sh diff --git a/.github/workflows/android.yaml b/.github/workflows/android.yaml index b881255f6094..3ce66c265e5c 100644 --- a/.github/workflows/android.yaml +++ b/.github/workflows/android.yaml @@ -143,3 +143,29 @@ jobs: path: | ~/.android/avd/* ~/.android/adb* + + agp9-compatibility: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + - uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b + with: + distribution: 'temurin' + java-version: '21' + - uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff + with: + channel: 'stable' + cache: true + cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:" + pub-cache-key: "flutter-pub-:os:-:channel:-:version:-:arch:-:hash:" + - uses: bluefireteam/melos-action@705015c3d2bc4ab94201ac24accb2bbe070cf533 + with: + run-bootstrap: false + melos-version: '5.3.0' + - name: 'Bootstrap tests package' + run: melos bootstrap --scope tests + - name: Gradle cache + uses: gradle/actions/setup-gradle@v4 + - name: 'Build tests app with AGP 9' + run: bash ./.github/workflows/scripts/agp9-compatibility.sh diff --git a/.github/workflows/scripts/agp9-compatibility.sh b/.github/workflows/scripts/agp9-compatibility.sh new file mode 100644 index 000000000000..6ed254165b93 --- /dev/null +++ b/.github/workflows/scripts/agp9-compatibility.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -euo pipefail + +AGP_VERSION="${AGP_VERSION:-9.0.1}" +GRADLE_VERSION="${GRADLE_VERSION:-9.1.0}" + +TEST_ANDROID_DIR="tests/android" + +perl -0pi -e "s/id \"com\.android\.application\" version \"[^\"]+\" apply false/id \"com.android.application\" version \"$AGP_VERSION\" apply false/" \ + "$TEST_ANDROID_DIR/settings.gradle" + +perl -0pi -e "s#distributionUrl=https\\\\://services.gradle.org/distributions/gradle-[^-]+-all.zip#distributionUrl=https\\\\://services.gradle.org/distributions/gradle-$GRADLE_VERSION-all.zip#" \ + "$TEST_ANDROID_DIR/gradle/wrapper/gradle-wrapper.properties" + +# AGP 9 has built-in Kotlin support. Keep the compatibility check focused on +# FlutterFire plugins by applying the same migration to the test app at runtime. +perl -0pi -e 's/\n\s*id "kotlin-android"\n/\n/' "$TEST_ANDROID_DIR/app/build.gradle" +perl -0pi -e 's/\n\s*kotlinOptions \{\n\s*jvmTarget = JavaVersion\.VERSION_17\n\s*\}\n/\n/' "$TEST_ANDROID_DIR/app/build.gradle" + +grep -q "id \"com.android.application\" version \"$AGP_VERSION\" apply false" "$TEST_ANDROID_DIR/settings.gradle" +grep -q "gradle-$GRADLE_VERSION-all.zip" "$TEST_ANDROID_DIR/gradle/wrapper/gradle-wrapper.properties" +! grep -q 'id "kotlin-android"' "$TEST_ANDROID_DIR/app/build.gradle" +! grep -q 'kotlinOptions' "$TEST_ANDROID_DIR/app/build.gradle" + +cd tests +flutter build apk --debug --dart-define=CI=true --no-android-gradle-daemon From 15ac86219770edf07d19abc6ffbac1ae885675e5 Mon Sep 17 00:00:00 2001 From: Guillaume Bernos Date: Tue, 28 Apr 2026 10:41:46 +0100 Subject: [PATCH 2/3] update --- .github/workflows/scripts/agp9-compatibility.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/scripts/agp9-compatibility.sh b/.github/workflows/scripts/agp9-compatibility.sh index 6ed254165b93..3d4e03e80b60 100644 --- a/.github/workflows/scripts/agp9-compatibility.sh +++ b/.github/workflows/scripts/agp9-compatibility.sh @@ -12,6 +12,12 @@ perl -0pi -e "s/id \"com\.android\.application\" version \"[^\"]+\" apply false/ perl -0pi -e "s#distributionUrl=https\\\\://services.gradle.org/distributions/gradle-[^-]+-all.zip#distributionUrl=https\\\\://services.gradle.org/distributions/gradle-$GRADLE_VERSION-all.zip#" \ "$TEST_ANDROID_DIR/gradle/wrapper/gradle-wrapper.properties" +# Flutter's Gradle plugin does not fully support AGP 9's new DSL yet. Opt out in +# this CI-only checkout so the job validates FlutterFire plugin compatibility. +# https://docs.flutter.cn/release/breaking-changes/migrate-to-agp-9/ +grep -q '^android.newDsl=false$' "$TEST_ANDROID_DIR/gradle.properties" || \ + printf '\nandroid.newDsl=false\n' >> "$TEST_ANDROID_DIR/gradle.properties" + # AGP 9 has built-in Kotlin support. Keep the compatibility check focused on # FlutterFire plugins by applying the same migration to the test app at runtime. perl -0pi -e 's/\n\s*id "kotlin-android"\n/\n/' "$TEST_ANDROID_DIR/app/build.gradle" @@ -19,6 +25,7 @@ perl -0pi -e 's/\n\s*kotlinOptions \{\n\s*jvmTarget = JavaVersion\.VERSION_17\n\ grep -q "id \"com.android.application\" version \"$AGP_VERSION\" apply false" "$TEST_ANDROID_DIR/settings.gradle" grep -q "gradle-$GRADLE_VERSION-all.zip" "$TEST_ANDROID_DIR/gradle/wrapper/gradle-wrapper.properties" +grep -q '^android.newDsl=false$' "$TEST_ANDROID_DIR/gradle.properties" ! grep -q 'id "kotlin-android"' "$TEST_ANDROID_DIR/app/build.gradle" ! grep -q 'kotlinOptions' "$TEST_ANDROID_DIR/app/build.gradle" From 310846085240fbe4f9581bd5ed04ee7c0e304aa1 Mon Sep 17 00:00:00 2001 From: Guillaume Bernos Date: Tue, 28 Apr 2026 10:48:58 +0100 Subject: [PATCH 3/3] update --- .github/workflows/scripts/agp9-compatibility.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/scripts/agp9-compatibility.sh b/.github/workflows/scripts/agp9-compatibility.sh index 3d4e03e80b60..9cf19d2c40ea 100644 --- a/.github/workflows/scripts/agp9-compatibility.sh +++ b/.github/workflows/scripts/agp9-compatibility.sh @@ -23,11 +23,22 @@ grep -q '^android.newDsl=false$' "$TEST_ANDROID_DIR/gradle.properties" || \ perl -0pi -e 's/\n\s*id "kotlin-android"\n/\n/' "$TEST_ANDROID_DIR/app/build.gradle" perl -0pi -e 's/\n\s*kotlinOptions \{\n\s*jvmTarget = JavaVersion\.VERSION_17\n\s*\}\n/\n/' "$TEST_ANDROID_DIR/app/build.gradle" +# AGP 9 rejects older Espresso artifacts that share the same namespace. +grep -q 'androidx.test.espresso:espresso-core:3.7.0' "$TEST_ANDROID_DIR/app/build.gradle" || cat <<'EOF' >> "$TEST_ANDROID_DIR/app/build.gradle" + +dependencies { + debugImplementation 'androidx.test.espresso:espresso-core:3.7.0' + debugImplementation 'androidx.test.espresso:espresso-idling-resource:3.7.0' +} +EOF + grep -q "id \"com.android.application\" version \"$AGP_VERSION\" apply false" "$TEST_ANDROID_DIR/settings.gradle" grep -q "gradle-$GRADLE_VERSION-all.zip" "$TEST_ANDROID_DIR/gradle/wrapper/gradle-wrapper.properties" grep -q '^android.newDsl=false$' "$TEST_ANDROID_DIR/gradle.properties" ! grep -q 'id "kotlin-android"' "$TEST_ANDROID_DIR/app/build.gradle" ! grep -q 'kotlinOptions' "$TEST_ANDROID_DIR/app/build.gradle" +grep -q 'androidx.test.espresso:espresso-core:3.7.0' "$TEST_ANDROID_DIR/app/build.gradle" +grep -q 'androidx.test.espresso:espresso-idling-resource:3.7.0' "$TEST_ANDROID_DIR/app/build.gradle" cd tests flutter build apk --debug --dart-define=CI=true --no-android-gradle-daemon