Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,29 @@
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

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Comment on lines +148 to +171
44 changes: 44 additions & 0 deletions .github/workflows/scripts/agp9-compatibility.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/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"

# 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"
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
Loading