在 Android Studio 中,如何让 Layout Inspector 显示更复杂的视图?

In Android Studio, how can I get the Layout Inspector to display more complex views?

我正在为 Android 应用编写自动化 UI 测试。但是,有时布局检查器无法显示视图层次结构,而是显示错误:

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.

我尝试了 中的解决方案,但 none 对我有用。我正在使用 Android Studio 3.5.2 并且 运行 物理设备上的应用程序。

有没有办法让布局检查器显示更复杂的视图?或者是否可以增加超时时间?

我找到了一个非正统的解决方案:Layout Inspector 有时 在将应用程序发送到后台时工作。视图将显示为非活动状态,但仍然可以查看它们的属性。