While taking the Device Screenshot (uiautomator dump) on UI Automator Viewer if you receive the below error
Error obtaining UI hierarchy
Reason:
Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException:
Remote object dosen’t exist!
Reason:
Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException:
Remote object dosen’t exist!

- The first option is to shutdown your appium server by pressing CTRL + C and then press y to Terminate batch job.
- The other solution is to kill the adb server and start again. Run the below commands in cmd to restart the adb server
adb kill-server
adb start-server
adb start-server