UIAutomatorviewer throws error

Hi guys,

I need your support to remove this error which is keep on coming while I’m using uiautomatorviewer.bat file for inspect elements.

Error :
Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Remote object doesn’t exist!

Following things i have already tried but it didn’t work :

  1. Stop Appium server.
  2. Disconnected mobile device & connect it back.
  3. Close the uiautomatorviewer.bat file & restart it again.

Please guys help me!!
Thanks in advance.

Whenever you open the uiautomatorviewer, please ensure the Appium server is not running in background.

Sometimes restarting the uiautomatorviewer a couple of times helps.

1 Like

Thanks for your quick reply.
It is working for only static page of an application. When i was taking screenshot of a page where numeric value is display & it is changing dynamically it throws same error again.

Try calling uiautomator through adb:

adb shell uiautomator dump

I suspect that will fail for the same reason. I’ve started seeing more screens that can’t be captured by uiautomator in apps developed on later version of Android, so you may be stuck. In the past, I’d usually get this error because I left the appium server running somewhere, so now I always check for that first.

Pages with dynamic animations will often fail (like a clock, timer, etc…).

What I do on those cases is launch application in debug mode and I place a break where I need to check the page. Then I run:

driver.getPageSource();

Then I copy the result to a xml viewer (p.e. http://codebeautify.org/xmlviewer) and I look for elements in there.

1 Like

Thanks for your reply. I have closed all appium node server in the background but still uiautomatorviewer display error for dynamic pages.

Hi Telmo_Cardoso,

Your reply help me a lot but could you please tell me how to differentiate the elements from the xml viewer. I have converter the xml into tree view but how we will come to know that which code(class/resource-id) is related to specific element.

Thanks,

This is the page which i was trying to capture.

I’m facing a similar issue and my app crashes as soon as i land on the screen where there is spinner view.

Hi Guys,

After launching the app in the emulator, I tried to locate the objects by uiautomateviewer but when i tried to capture the screenshot it throws the error as “Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Remote object doesn’t exist!”.

I tied with the above steps like stopping the appium and tried to capture the sreen shot via UIautomatorviewer.

But after stopping the appium server(Ctrl+C from command prompt) automatically the launched app in emulator gets terminated. So because of this i can’t able to capture the screen shot and identify the obeject values.

Please help me to solve this issue.

Hello guys,

I freshly installed appium setup in my laptop and while opening Uiautomatorviewer, it is shoing me the error’ A JNI error has occurred. Please check your administrator and try again’
When i click ‘OK’ there, then msg comes ‘A JAva exception has occurred’

Please lemme know how it can be resolved.

Hello,

UI automator is not capturing the screenshot of android mobile, showing message like
"Error obtaining UI hierarchy.
Reason : Unexpected error while obtaining UI hierarchy "

Device : Nokia 6.1
API : 27
Android version : 8.0.1

Tried all the solutions posted above, still not able to resolve this error.
Guys, please help me in this.

Thanks in advance.

Regards,
Shital

When I tried to launch the uiautomatorviewer . i am getting below error. I am trying on mac and using JAVA java 10.0.2 . Can you please some one help on the same?

Last login: Thu Aug 9 22:41:34 on ttys002
LBELALAD-M-91G4:~ lbelalad$ uiautomatorviewer
-Djava.ext.dirs=/Users/lbelalad/Library/Android/sdk/tools/lib/x86_64:/Users/lbelalad/Library/Android/sdk/tools/lib is not supported. Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Is there any workaround to this ?
Presently if the appium server is running, the UIAutomator cannot get the screenshot and page source from the device.

I think many of us would want the UIAutomator to work even if appium server is running, so that we can debug the code in Eclipse and also try different mechanisms.
This will reduce our effort.

Hi guys,

It seems like the issue is on uiautomatorviewer.

This is what I’ve been doing:

  1. Save the following commands as a batch or shell script.

adb shell uiautomator dump
adb pull /sdcard/window_dump.xml ui.uix
adb shell screencap -p /sdcard/ui.png
adb pull /sdcard/ui.png .

  1. Run the script. It will generate ‘ui.uix’ and ‘ui.png’ files in current directory.
  2. Load the ‘ui.uix’ and ‘ui.png’ files into ui automator viewer by clicking ‘Open’ button.
5 Likes

Hi
make sure the appium server is not running. Device is recognized via adb.
workaround is to use appium inspector

Thanks for this solution…it works for me :slightly_smiling_face:

1 Like

Thank you very much! This is not a fix, but a good workaround.

Awesome TQ:). This script is working fine. But the button on the UIAUViwer is throwing error “EOF”

This worked.

Thanks!

1 Like