Unexpected error while observing UI hierarchy

solution: adjust to manual screenshot
principle: obtain the UI layout information of the current window and the screenshot of the current page through the ADB command, copy and send it to the computer, and then manually add the screenshot and file through uiautomatorview to analyze and locate the mobile phone elements
first step
You can first create a folder named test in the sdcard directory of your mobile phone
Step 2
open the CMD command line, and enter

adb shell uiautomator dump /sdcard/test/app.uix

# command explanation: output the UI layout information of the current window and input it to/sdcard/test/ app.uix Within the document( app.uix The file does not need to be created manually, and the command will be generated automatically). in this step, the CMD command line will report an error, but the final result will not be affected;
in the third step, the

adb shell screencap -p /sdcard/test/app.png

# command explanation: the ADB mobile phone screenshot command intercepts the current page and saves it to the mobile phone test folder (the mobile phone should be kept unlocked, otherwise the captured picture is pure black);
after completing these two steps, there should be two files in the/sdcard/test folder of the mobile phone
app.png Pictures captured for mobile phones
1 app.uix In order to capture the UI layout information of the image (later, the analysis elements can be operated through uiautomatiorview)
Step 4 of

adb pull /sdcard/test/app.uix E:/app.uix

?Command explanation: the app.uix File copy e disk
Step 5

adb pull /sdcard/test/app.png E:/app.png

Command explanation: copy the captured image to the e disk directory of the computer

at the same time, the two files of the computer should be as follows:

Step 6
Open UI autoviewer
screenshot select the PNG end picture of disk e, that is, the screenshot of the mobile phone
UI XML dump select the uix end file of disk e, that is, the layout information of the screenshot of the mobile phone

screen These commands can be written as bat files. You need to take a screenshot and run the bat file directly. The contents are as follows ( note: each saved screenshot will cover the previous screenshot ):

@echo on
adb shell uiautomator dump /sdcard/test/app.uix
adb shell screencap -p /sdcard/test/app.png
adb pull /sdcard/test/app.uix E:/app.uix
adb pull /sdcard/test/app.png E:/app.png

Read More: