Android 布局检查器因超时错误而失败

Android Layout Inspector fails with timeout error

当我尝试通过 Tools => Layout Inspector 在模拟器中检查我的应用程序布局时,它总是失败并出现以下错误之一:

1.

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.

2.

No active windows displayed by com.instabridge.android.dev

布局不是特别复杂,也没有动画,只是配了一些视图。 Android Studio 是 3.4.1。我如何解决它?或者如何找到错误的原因?

尽量使用真实设备而不是模拟器。 当 运行 连接模拟器和 android 工作室时,您的 laptop/mac/whatever 可能 运行 内存不足。

我总是更喜欢 运行 真实物理设备上的布局检查器。连接 adb

后,它与模拟器的工作方式相同

我在 Android Studio 3.4 上遇到了同样的问题,但我能够在 Android Studio 上使用 Layout Inspector 3.5 Beta 1 没有任何问题。

我正在处理一个非常复杂的视图,所以我怀疑这就是导致 Android Studio 3.4 出现问题的原因。我看到的失败和成功都是物理设备。

找到了一个非常奇怪的解决方案。

打开您的应用,转到 android 主屏幕,打开另一个应用,现在使用 Android Studio 中的布局检查器。

成功了,我看到了我的应用程序的视图层次结构。

更新

P.Melch 声称您甚至不需要打开另一个应用程序,尝试将您的应用程序发送到后台。