"additional_test_output" 来自 Android 仪器化测试?

"additional_test_output" from Android Instrumented Tests?

运行 Android 仪器测试,gradle 任务 :app:connectedDebugAndroidTest 现在在成功测试后打印红色警告 运行:

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)
    ...

确实模拟器没有这个文件,但是之前测试没想到会创建。

问. 有办法解决这个警告吗?这是一个测试协调器错误吗? (我不打算破解测试来创建一个空文件。)

环境: Android MBP 工作室,com.android.tools.build:gradle:7.1.1androidx.test:orchestrator:1.4.1,Android 模拟器 API 级别 26 - 32,一些有一些没有 Google APIs;也在 API 级别 31 的 Pixel 3 设备上。

在 API 级别 21 - 25 的模拟器上,它会打印(而不是刺眼的红色文本):

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

降级 Gradle 对我有用

成功: 从版本 7.1.2 升级 Android Gradle 插件 -> 版本 7.2.0-beta04 修复了这个问题!

AGP release notes 说 AGP 7.2 需要 Gradle 版本 7.3+,所以我选择了最新版本,目前是 Gradle版本 7.4.1。 (仅升级 Gradle 并不能解决问题。这并不奇怪,因为该问题特定于 Android 测试。)

步骤:

  1. 打开 Android Studio 的 File > Project Structure... 对话框。
  2. 选择 Android Gradle 插件版本 7.2.0-beta04 或更高版本。 (在 7.2+ 的完整版本发布之前,我更喜欢 beta 版本而不是 7.3 alpha。)
  3. 选择 Gradle 版本 7.3 或更高版本。
  4. 好的。
  5. Build > Rebuild Project 以防万一。