Android Layout Inspector fails with timeout error


When I try to inspect my application's layout in a simulator, by going Tools => Layout Inspector, it always fails with one of the errors:


Error obtaining view hierarchy: There was a timeout error capturing the layout data from the device.
The device may be too slow, the captured view may be too complex, or the view may contain animations.

Please retry with a simplified view and ensure the device is responsive.


No active windows displayed by

The layout is not particularly complex, and it does not contain animations, just map with some views. Android Studio is 3.4.1. How do I fix it? Or how to find the cause of the errors?

Best Solution

Found a really strange solution.

Open your app, go to android home screen, open another app, now use Layout inspector in Android Studio.

It worked and I see my app's view hierarchy.


P.Melch claims that you don't even need to open another app, try just sending your app to background.