Android 9 系统 Uiautomatorviewer 使用报错解决方法

今天我准备使用 Uiautomatorviewer 对小米8手机进行调试时出现报错,无法获取UI信息(系统版本 android 9)。

Android 9 系统 Uiautomatorviewer 使用报错解决方法_第1张图片
Uiautomatorviewer 抓取报错信息.PNG

问题出现的原因是:android 8以后sdk自带的uiautomator直接打开,截取不到机器界面信息。

建议可以使用以下方法手动截取(adb命令)。

1.截取uix文件,并转移到电脑E盘根目录

adb shell uiautomator dump /sdcard/app.uix

adb pull /sdcard/app.uix E:/app.uix

2.截取截图,并转移到电脑E盘根目录

adb shell screencap -p /sdcard/app.png

adb pull /sdcard/app.png E:/app.png

3.打开sdk tools目录下的uiautomatorviewer.bat,导入从机器获取的截图和资源文件


Android 9 系统 Uiautomatorviewer 使用报错解决方法_第2张图片
Android 9 系统 Uiautomatorviewer 使用报错解决方法_第3张图片

因为每次都得写四行代码,比较麻烦所以写了一个小bat文件,
放到桌面直接运行即可

新建一个文本文档,名字自己起如uni.bat(注意把后缀给改成.bat)

@echo on

adb shell uiautomator dump /sdcard/app.uix
adb pull /sdcard/app.uix E:/app.uix
adb shell screencap -p /sdcard/app.png
adb pull /sdcard/app.png E:/app.png

你可能感兴趣的:(Android 9 系统 Uiautomatorviewer 使用报错解决方法)