真机Android 8.0版本以上uiautomator定位元素-Unsupported protocol: 2/Unexpected error while obtaining UI hierarc

uiautomator截屏报错Screenshot: Unsupported protocol: 2

1.确保adb devices可以看到真机设备,有的话可以进入下一步

2.下载ASM程序:https://code.google.com/p/android-screen-monitor/downloads/list,直接下载即可

3.根据你的习惯,可以放在你习惯的任何位置上,我的是直接拷贝到tools目录下

4.在cmd中输入命令:java -jar "D:\adt-bundle-windows-x86_64-20140702\sdk\tools\androidscreencast-0.0.12s-executable.jar"

5.如果你的手机是连接在电脑的,并且处于可调式状态,那么OK之后,你就可以看到你的手机屏幕:

 uiautomator截屏报错Error obtaining UI hierarchy

android8.1以后sdk tools自带的uiautomator直接打开,截取不到设备界面信息。

可以使用以下方法手动截取。

首先操作设备定位到要分析的界面。

1.截取uix资源文件

adb shell uiautomator dump /sdcard/screen.uix

adb pull /sdcard/screen.uix D:/screen.uix

2.截取截图

adb shell screencap -p /sdcard/screen.png

adb pull /sdcard/screen.png D:/screen.png

运行sdk/tools目录下的uiautomatorviewer.bat,导入从设备获取的截图和资源文件

 

猜你喜欢

转载自blog.csdn.net/test_leader/article/details/113651373