Can't seem to launch Layout Inspector on Android Studio 3.0 (Canary 3)
似乎无法在Android Studio 3.0 (Canary 3)上推出布局检查器
When connected to my device and app running, choosing Tools > Android > Layout Inspector comes up with the following error dialog:
当连接到我的设备和app运行时,选择工具> Android > Layout Inspector,会出现以下错误对话框:
"Error obtaining view hierarchy: Unexpected error: empty view hierarchy"
“获取视图层次结构的错误:意外错误:空视图层次结构”
Any setup I'm missing? I have Developer Options enabled on the device.
设置我失踪吗?我在设备上启用了开发人员选项。
5 个解决方案
#1
4
I can't launch my hierarchy viewer while playing video. Once I pause the video, it works!
我不能在播放视频时启动层级查看器。一旦我暂停视频,它就可以工作了!
#2
3
If you have ViewTreeObserver
in your code to measure a view's width/height, and you're changing some width/height/padding/etc. according to a result you are getting from addOnPreDrawListener
of ViewTreeObserver;
如果在代码中有ViewTreeObserver来度量视图的宽度/高度,并且您正在更改一些宽度/高度/填充等等。根据来自ViewTreeObserver的addOnPreDrawListener的结果;
Just comment inside onPreDraw
or comment all code related to ViewTreeObserver
.
只需要在onPreDraw或注释中注释所有与ViewTreeObserver相关的代码。
#3
1
This could be related to your Android version. For example, in my case, this error occurs on Genymotion on Android 4. After moving to Android 5 this error gone.
这可能与你的Android版本有关。例如,在我的例子中,这个错误发生在Android 4上的Genymotion上。在移动到Android 5之后,这个错误消失了。
#4
0
Had same problem on Android Studio v2.3.3, problem was related to CountDownTimer Object, somehow it cause problem (probably because of onTick method). After commenting it, I could normally use Layout Inspector. Maybe you use something similar in your code, try to comment it out and see if if works.
在Android Studio v2.3.3上也有同样的问题,问题与CountDownTimer对象有关,不知何故导致了问题(可能是因为onTick方法)。在注释之后,我通常可以使用Layout Inspector。也许你在代码中使用了类似的东西,试着注释掉它,看看是否有效。
#5
0
In general I've this behavior when something is "moving" in the view so the layout inspector cannot retrieve a simple layout, that's why pausing a video will work but if you have something more complex like camera preview or Google Map is harder, not sure how to work around this
一般来说,当视图中有东西在“移动”时,我就会有这种行为,因此布局检查器不能检索简单的布局,这就是暂停视频的原因,但是如果你有更复杂的东西,比如camera preview或谷歌Map,就比较难了,不知道该如何解决这个问题
#1
4
I can't launch my hierarchy viewer while playing video. Once I pause the video, it works!
我不能在播放视频时启动层级查看器。一旦我暂停视频,它就可以工作了!
#2
3
If you have ViewTreeObserver
in your code to measure a view's width/height, and you're changing some width/height/padding/etc. according to a result you are getting from addOnPreDrawListener
of ViewTreeObserver;
如果在代码中有ViewTreeObserver来度量视图的宽度/高度,并且您正在更改一些宽度/高度/填充等等。根据来自ViewTreeObserver的addOnPreDrawListener的结果;
Just comment inside onPreDraw
or comment all code related to ViewTreeObserver
.
只需要在onPreDraw或注释中注释所有与ViewTreeObserver相关的代码。
#3
1
This could be related to your Android version. For example, in my case, this error occurs on Genymotion on Android 4. After moving to Android 5 this error gone.
这可能与你的Android版本有关。例如,在我的例子中,这个错误发生在Android 4上的Genymotion上。在移动到Android 5之后,这个错误消失了。
#4
0
Had same problem on Android Studio v2.3.3, problem was related to CountDownTimer Object, somehow it cause problem (probably because of onTick method). After commenting it, I could normally use Layout Inspector. Maybe you use something similar in your code, try to comment it out and see if if works.
在Android Studio v2.3.3上也有同样的问题,问题与CountDownTimer对象有关,不知何故导致了问题(可能是因为onTick方法)。在注释之后,我通常可以使用Layout Inspector。也许你在代码中使用了类似的东西,试着注释掉它,看看是否有效。
#5
0
In general I've this behavior when something is "moving" in the view so the layout inspector cannot retrieve a simple layout, that's why pausing a video will work but if you have something more complex like camera preview or Google Map is harder, not sure how to work around this
一般来说,当视图中有东西在“移动”时,我就会有这种行为,因此布局检查器不能检索简单的布局,这就是暂停视频的原因,但是如果你有更复杂的东西,比如camera preview或谷歌Map,就比较难了,不知道该如何解决这个问题