获取手机UI元素时报错:Unexpected error while obtaining UI hierarchy java.lang.reflect.InvocationTargetExceptio

获取手机UI元素时报错:Unexpected error while obtaining UI hierarchy java.lang.reflect.InvocationTargetException

昨晚,在使用uiautomatorviewer.bat 这个工具的过程中出现了如下提示

获取手机UI元素时报错:Unexpected error while obtaining UI hierarchy java.lang.reflect.InvocationTargetExceptio

经过排查发现可能是Android版本太高(我的是安卓10)导致旧的SDK包无法获取UI界面元素。因此,决定重新安装SDK

首先下载新的SDK工具包和platform-tools工具包

下载地址:https://www.techspot.com/downloads/5425-android-sdk.html

获取手机UI元素时报错:Unexpected error while obtaining UI hierarchy java.lang.reflect.InvocationTargetExceptio

然后将platform-tools工具解压并放到Android SDK工具包里面,像这样:

获取手机UI元素时报错:Unexpected error while obtaining UI hierarchy java.lang.reflect.InvocationTargetExceptio

然后配置adb环境变量:

获取手机UI元素时报错:Unexpected error while obtaining UI hierarchy java.lang.reflect.InvocationTargetExceptio

然后启动:

获取手机UI元素时报错:Unexpected error while obtaining UI hierarchy java.lang.reflect.InvocationTargetExceptio

大功告成:

获取手机UI元素时报错:Unexpected error while obtaining UI hierarchy java.lang.reflect.InvocationTargetExceptio

上一篇:13.QCustomPlot 类层次结构-图


下一篇:GA006-182-18组