仅当某些特定应用 运行 时才会出现屏幕截图问题

problems taking screenshot only when some specific apps are running

我在使用某些特定应用程序在模拟器中截取屏幕截图时遇到问题:如果应用程序不是 运行(例如在主屏幕上),则截屏(通过 monkeyrunner 或 adb)工作正常,但在 monkeyrunner 或returns 通过 adb 截取屏幕截图时大小为 0 的文件。我已经通过在不同的应用程序 运行 时截屏来验证行为,所以截屏的过程很好。使用不同的渲染器时问题仍然存在,例如使用 -gpu swiftshader_indirect 或 -gpu guest 的行为是相同的,因此它与渲染器无关。此外,我已经使用多个不同的 AVD 配置文件检查了行为,例如Pixel、Pixel 2、Nexus 5X 和多个 API 版本(25、27、28)。在 Ubuntu 18.04.

上使用 Android 模拟器版本 28.0.22.0 (build_id 5194135)

adb 中没有错误 shell,只有零大小的文件:

generic_x86:/ $ screencap -p /sdcard/screen.png
generic_x86:/ $ ls -la /sdcard/screen.png
-rw-rw---- 1 root sdcard_rw 0 2019-02-18 15:29 /sdcard/screen.png

Monkeyrunner 输出如下所示:https://kajala.com/monkeyrunner-output.txt

有什么想法吗?

一件事阻碍了 screenshots/screencasts — 至少 in part — is FLAG_SECURE。如果有问题的应用程序正在使用 FLAG_SECURE,我希望症状会让人联想到您所看到的。