Search code examples
androidandroid-test-orchestrator

"additional_test_output" from Android Instrumented Tests?


Running Android Instrumented Tests, the gradle task :app:connectedDebugAndroidTest now prints a red WARNING after a successful test run:

Feb 12, 2022 11:53:02 PM com.android.tools.utp.plugins.host.additionaltestoutput.AndroidAdditionalTestOutputPlugin deviceShellAndCheckSuccess
WARNING: Shell command failed (1): ls "/sdcard/Android/media/<APP_NAME>/additional_test_output"
ls: /sdcard/Android/media/<APP_NAME>/additional_test_output: No such file or directory

Feb 12, 2022 11:53:02 PM com.android.tools.utp.plugins.host.additionaltestoutput.AndroidAdditionalTestOutputPlugin afterAll
WARNING: Failed to retrieve additional test outputs from device.
com.android.ddmlib.SyncException: Remote object doesn't exist!
    at com.android.ddmlib.SyncService.pullFile(SyncService.java:341)
    ...

Indeed the emulator has no such file, but the test has not been expected to create it before.

Q. Is there a way to fix this warning? Is it a test orchestrator bug? (I'm not planning to hack the test to create an empty file.)

Environment: Android Studio on MBP, com.android.tools.build:gradle:7.1.1, androidx.test:orchestrator:1.4.1, on Android emulators for API levels 26 - 32, some with and some without Google APIs; also on a Pixel 3 device at API level 31.

On emulators for API levels 21 - 25, it prints instead (not in glaring red text):

additionalTestOutput is not supported on this device running API level 25 because the additional test output directory could not be found

Solution

  • Success: Upgrading the Android Gradle Plugin from Version 7.1.2 -> Version 7.2.0-beta04 fixes this problem!

    The AGP release notes say that AGP 7.2 requires Gradle Version 7.3+, so I picked the latest release, which is currently Gradle Version 7.4.1. (Upgrading just Gradle does not fix the problem. That's not surprising since the problem is specific to Android testing.)

    Steps:

    1. Open Android Studio's File > Project Structure... dialog.
    2. Pick Android Gradle Plugin Version 7.2.0-beta04 or later. (Until there's a full release of 7.2+, I prefer beta release over a 7.3 alpha.)
    3. Pick Gradle Version 7.3 or later.
    4. OK.
    5. Build > Rebuild Project just in case.