Gradle

Misc commands

restart adbadb kill-server
adb start-server
stop./gradlew --stop
run in debugflutter run --debug
Can then use interactive command line.
list tasks.\gradlew tasks --all
Download missing android dependencies./gradlew dependencies # In android directory

Building

Ref: https://firebase.google.com/docs/test-lab/android/continuous Ref: https://docs.flutter.dev/testing/integration-tests Ref: https://developer.android.com/training/testing/espresso/setup Ref: https://developer.android.com/studio/test/command-line

Rebuilding./gradlew clean build --stacktrace
Debug apkflutter build apk --debugbuild/app/outputs/apk/debug/app-debug.apk
target debug apk.\gradlew.bat app:assembleDebug -Ptarget="D:/working/flipdare/app-test/dex_fix2/integration_test/dev_fix_test.dart"build/app/outputs/apk/debug/app-debug.apk
./gradlew app:assembleDebug -Ptarget=integration_test/dex_fix_test.dart
target test apk.\gradlew.bat app:assembleAndroidTest -Ptarget="D:/working/flipdare/app-test/dex_fix2/integration_test/dev_fix_test.dart"build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk
./gradlew app:assembleAndroidTest -Ptarget=integration_test/dex_fix_test.dart
Build the apkflutter build appbundle --target-platform android-arm,android-arm64
Generate arm/intelflutter build apk --debug --split-per-abi --target=integration_test/flipdare_store_test.dart

Note, what is specified at https://github.com/flutter/flutter/tree/main/packages/integration_test#android-device-testing

./gradlew app:assembleAndroidTest
./gradlew app:assembleDebug -Ptarget=<path_to_test>.dart

Testing

Ref: https://developer.android.com/studio/test/command-line

integrationflutter drive --driver=test_driver/integration_test.dart --target=integration_test/dex_fix_test.dart
Orchestration./gradlew connectedCheckThis keeps failing because of R8 errors.
Individual test./gradlew testVariantNameUnitTest --tests '*.sampleTestMethod'

Killing gradle on windows

WMIC PROCESS where "Name like 'java%' AND CommandLine like '%GradleDaemon%'" Call Terminate
WMIC PROCESS where "Name like 'java%' AND CommandLine like '%.gradle%'" Call Terminate

Changing gradle/kotlin version

  • Edit gradle.properties and add:

      `distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip` 
    

Gradle Server

$Env:PATH = "C:\Program Files\Android\Android Studio\jre\bin;$Env:PATH"
C:\google-cloud\flutter-test\test_theme\android> ./gradlew wrapper
C:\google-cloud\flutter-test\test_theme\android> gradle

$Env:PATH = "C:\Program Files\Android\Android Studio\jre\bin;$Env:PATH"
cd D:\flipdare\flutter-test\test_snack\android/
./gradlew wrapper

stop w rapper

 ./gradlew --stop

Add the following line to android/build.gradle

println(com.android.tools.r8.Version.getVersionString())

And run

.\gradlew
8.2.42 (build 12d495d9e6e5d8ba2b5a930d3881401415efc9b2 from go/r8bot (luci-r8-custom-ci-archive-0-dyvc))

Get the latest NDK version for compiler errors

https://developer.android.com/ndk/downloads

Changing build versions

buildscript {
    ext.agpVersion = "8.1.1"
    repositories {
        // Insert local test repo here
        google()
        mavenCentral()
    }
    ...
}

ext {
    buildToolsVersion = "32.0.0"
    androidxAnnotationVersion = "1.5.0"
    guavaVersion = "31.1-android"
    coreVersion = "1.6.0-alpha01"
    extJUnitVersion = "1.2.0-alpha01"
    runnerVersion = "1.6.0-alpha03"
    rulesVersion = "1.6.0-alpha01"
    espressoVersion = "3.6.0-alpha01"
    truthVersion = "1.1.3"
}

Local Testing

Ref: https://github.com/flutter/flutter/tree/main/packages/integration_test

Integration tests (with drive)flutter drive --driver=integration_test/driver.dart --target=integration_test/app_test.dart -d "emulator-5554"
flutter drive --driver=test_driver/integration_test.dart --target=integration_test/flipdare_store_test.dart
Integration test (new)flutter test integration_test
Adb verifyadb.exe shell pm list instrumentation
Adb runadb.exe shell am instrument -w com.flipdare.store.MainActivityTest

Misc testing (including with coverage)

flutter test
flutter test --reporter expanded
flutter test --reporter expanded --verbose
flutter test --coverage  

Google Testlab

Setup

logingcloud auth login
updategcloud components update
set projectgcloud config set project flipdare-test

Devices

Ref: https://firebase.google.com/docs/test-lab/android/available-testing-devices Ref: https://firebase.google.com/docs/test-lab/android/avds Ref: https://cloud.google.com/sdk/gcloud/reference/firebase/test/android/run

  • Note, The Google Play Store App is unsupported on Arm virtual devices.
MODEL_ID and OS_VERSION_IDgcloud firebase test android models list
OS_VERSION_ID and VERSIONgcloud firebase test android versions list
Virtual Devicesgcloud firebase test android models list --filter=virtual
Supported abi infogcloud firebase test android models describe SmallPhone.arm
Android only modelsgcloud firebase test android models list

Using orchestrator

Ref: https://developer.android.com/training/testing/instrumented-tests/androidx-test-libraries/runner

Deploying to testlab

Ref: https://medium.com/firebase-developers/google-firebase-test-lab-integration-for-flutter-integration-tests-38f903d47ac3

gcloud firebase test android run \
	--type instrumentation \
	--app build/app/outputs/apk/debug/app-debug.apk \
	--test build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk \
    --timeout 2m \
    --results-bucket=gs://flipdare-test.appspot.com \
    --results-dir=test/store \
	--device model=Pixel2,version=30,locale=en,orientation=portrait