报错信息
Unexpected error while obtaining UI hierarchy
details:
Unexpected error while obtaining UI hierarchy
java.lang.reflect.InvocationTargetException
问题原因
android8.1以后sdk tools自带的uiautomator直接打开,截取不到设备界面信息
解决方案
1.截取设备界面资源
(1)截取uix资源文件
adb -s GBGDU19924002753 shell uiautomator dump /sdcard/screen.uix
adb -s GBGDU19924002753 pull /sdcard/screen.uix .
(2)截取界面截图
adb -s GBGDU19924002753 shell screencap -p /sdcard/screen.png
adb -s GBGDU19924002753 pull /sdcard/screen.png .
2.启动sdk uiautomatorviewer,具体命令如下
cd sdk/tools
./uiautomatorviewer
点击Open
3.导入步骤1获取的界面资源,即可正常定位华为P30元素信息
参考:https://www.cnblogs.com/copyworker/p/11043705.html