28

I am testing my app with adb, but i get this error when i execute "dump view hierarchy for uiautomator":

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

My adb version is 1.0.36 and my android version is 6.0.1.

This error comes launched only when in the interface there is a dynamic element that is in motion.

thank you in advance.

Ale7
  • 401
  • 1
  • 5
  • 7

14 Answers14

33

The best way is to kill the adb server and start it again.

  • sudo adb kill-server
  • sudo adb start-server

This will do the trick.

Hitesh Grover
  • 347
  • 3
  • 5
18

Currently your UI needs to be idle (as in no Accessibility Events sent) for at least 1000ms before the AccessibilityService will be able to produce the UI hierarchy dump.

If you would try to run adb shell uiautomator dump it would give you the ERROR: could not get idle state.

Alex P.
  • 30,437
  • 17
  • 118
  • 169
  • if i wanted to test an app not made by me but with the same problem? thank you in advance. – Ale7 Oct 24 '16 at 14:07
  • it's a limitation of the AccessibilityService itself. I am guessing that an app changing its UI more frequently than once per second is not considered *accessible* – Alex P. Oct 24 '16 at 15:27
  • therefore doesn't exist solution at this issue if i use adb? Thank you again. – Ale7 Oct 24 '16 at 15:35
11

Even though it's late I'm giving my observation here. Even I got this issue. Before taking the screen shot from UI Automator terminate the appium server connection. Then try to capture screenshot. It works fine.

snadella
  • 111
  • 1
  • 6
9

I realise this is an old post. But I've noticed the same issue when I've use uiautomator to control the simulator for automation testing. It seems that the uiautomatorviewer does not connect to the emulator to take a screenshot after the emulator has been controlled by the uiautomator.

I found that running adb reconnect allows the uiautomatorviewer to take screenshots again.

Stuart
  • 1,544
  • 5
  • 29
  • 45
8

Try Restarting your device, which worked in my case.

Saurabh Shukla
  • 458
  • 6
  • 8
4

If you are getting this error

enter image description here

This means your UI Automator is got disconnected, to regain the connection, you can open the new terminal no need to worry about the location on the terminal.

Type the command

adb reconnect

and try again to take a screenshot it should work.

Vinay Pandey
  • 113
  • 5
3

in the device or emulator :

  1. display the applications opened , and close them one by one.

  2. refresh monitor.

    It should now be able to and get the hierarchies, as if one of the apps opened was "obfuscating" the parsing.

3

The below command executed from command line worked for me;

adb shell am force-stop com.android.ddmlib
Samantha
  • 921
  • 9
  • 12
2

Close other AccessibilityService in your phone please.

jp1017
  • 81
  • 11
1

Rebooting the device worked for me.

rajkabbur
  • 187
  • 3
1

For those people who encountered this issue due to changes to the Accessibility Events faster than once a second.

ERROR: could not get idle state.

I found a comment on AndroidViewClient which is based on uiautomator where the author says that CulebraTester2-public exposes this functionality.

https://github.com/dtmilano/AndroidViewClient/issues/189#issuecomment-570775719

https://github.com/dtmilano/CulebraTester2-public is not affected by this problem.

It can be used to dump the hierarchy and also as an AndroidViewClient backend.

https://github.com/dtmilano/CulebraTester2-public https://github.com/dtmilano/CulebraTester2-client

I ran a simple test and it seems to work in my case.

Peter
  • 443
  • 4
  • 9
  • glad to hear it works in your case. A simple test that can be run in that situations, to verify the difference, is the one described at https://github.com/dtmilano/CulebraTester2-public#androidviewclient; including or excluding `--use-uiautomator-helper` should show a successful dump or the error. Another advantage is that the dump could be in json. – Diego Torres Milano Feb 24 '22 at 21:21
0

I have tried all the above steps and none of them did not work. The reason being I have tried to run the uiautomatorviewer after opening the app using Appium. Whenever I manually open my app on the device and then run the uiautomatorviewer works perfectly well. Just sharing my experience. Thanks

Bob Jones
  • 171
  • 1
  • 4
  • 22
  • 3
    try `adb reconnect`. I've had the same issue. once the app is controlled via adb, it locks to that source. `adb reconnect` unlocked it for uiautomatorviewer to gain control and take the screenshot. – Stuart Jul 29 '20 at 09:45
  • Same. I've tried all but still facing the same issue! – Mohsin Awan Mar 29 '21 at 18:32
0

By enable the developer option and usb debugging , issue resolve for me

lux man
  • 11
  • 1
-1

Before taking the screen shot from "uiautomatorviewer" please terminate the appium server connection by using ctrl+C command. Then try to capture screenshot. It works fine.

Shashi
  • 21