uiautomatorviewer不支持安卓 9.0或以上,提示:"error: obtaining UI hierachy"解决方法

 

 安卓系统升级到9后使用会报错,

之前有介绍过使用:uiautomator2  weditor  解决,有兴趣也可以了解下:https://www.cnblogs.com/shoebill/p/10776353.html

 

具体解决方案如下:

方案一:

#可以通过adb命令从手机导出文件,
#1.手机通过usb链接电脑,
adb devices #打印链接手机设备信息,并检测时间链接成功

#2 导出所需文件到PC端
adb shell uiautomator dump /sdcard/app.uix
adb pull /adcard/app.uix D:/app.uix
#存到D盘的app.uix文件中

adb shell screencap -p /sdcard/app.png
adb pull /sdcard/app.png D:/app.png

 

方案二:写个一个bat文件,放到桌面直接运行即可;

新建一个文本文档,名字自己起,如:uni.bat

内容如下:

#导出所需文件到PC端
adb shell uiautomator dump /sdcard/app.uix
adb pull /adcard/app.uix D:/app.uix
#存到D盘的app.uix文件中

adb shell screencap -p /sdcard/app.png
adb pull /sdcard/app.png D:/app.png

 

从上面两个方案会得到两个文件,分别导入到 uiautomatorviewer

 

其实还是存在有缺陷,上述的解放方案是通过截图来定位每个元素,切换了页面也需要重新截图上传比较麻烦,

建议还是用:uiautomator2  weditor

或者用adb命名导出每个页面的元素和activity

 

 参考文献:

https://blog.csdn.net/weixin_39844549/article/details/110483746?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&dist_request_id=40056850-45bc-4db6-a846-3914e1d8b61e&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control

posted @ 2021-02-22 10:56  沙丘蚂蚁慢慢爬  阅读(486)  评论(0编辑  收藏  举报