Sometimes when we try to capture the screenshot using UI Automator Viewer then the following error is displayed and the screenshot is not captured.
Error obtaining UI hierarchy
Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Remote object doesn't exist!
There is no configuration issue that stops the application taking the screenshot but the reason is that Appium server is running in the backend and it stops UI Automator Viewer to capture the screenshot. The best solution is that to stop the Appium server first and then take the snapshot. Now, you would be able to capture the screenshot.