Tag Archives: Uiautomatorviewer error

[Solved] uiautomatorviewer Error: Error obtaining UI hierarchy

1. Problem reappearance: when learning appium framework and using uiautomatorviewer to locate Android App controls, directly selecting [device screenshot] will report an error:

2. Solution:

Create a new bat file with the following contents:

adb shell uiautomator dump /sdcard/screen.uix
adb pull /sdcard/screen.uix D:/uiscreen/screen.uix
adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png D:/uiscreen/screen.png

In fact, these commands can also be directly input in CMD, but they need to be input every time, which is more troublesome. All commands can be written into bat files and run directly to obtain interface information.

3. Select the path of the picture and uix file in uiautomatorviewer:

My frame is too small. I can’t click the path of the second uix at all. The solution is to press the tab key, locate the button to select the file, and then enter can select it normally.

4. Then you can load the interface and locate the elements normally.

Uiautomatorviewer Error: Unexpected error while obtaining UI hierarchy java.lang.reflect.InvocationT…

1.Error report screenshot

After Android 8, the UI Automator of the SDK is opened directly, and the machine interface information cannot be intercepted.

It is recommended that you can use the following methods to intercept manually

2.Solutions

1. Intercept the uix file

adb shell uiautomator dump /sdcard/ sc.uix

adb pull /sdcard/ sc.uix

Note: the new mobile address is changed to/data/local/TMP/*. Uix

2. Screenshot

adb shell screencap -p /sdcard/ sc.png

adb pull /sdcard/ sc.png

3. Open the uiautomatorviewer.bat , import the screenshot and resource file obtained from the machine

3、 Screenshot after solution