简体   繁体   English

Android Studio 4.0 布局检查器不工作

[英]Android Studio 4.0 Layout Inspector isn't working

I can't see any updates in Layout Inspector in the new Android studio (4.0).我在新的 Android 工作室 (4.0) 中看不到任何布局检查器的更新。

My app is targeting API 29, and build tools version is buildToolsVersion '29.0.3' .我的应用程序的目标是 API 29,构建工具版本是buildToolsVersion '29.0.3'

I'm running emulator Pixel_2_api_29 and my device MI A3 OS version 10 .我正在运行模拟器Pixel_2_api_29和我的设备MI A3 OS version 10

And this is all I can see这就是我所能看到的布局检查器android studio 4.0

In the tools->SDK Manager window, please verify that Layout Inspector Image Server for API 29-30 is installed.在工具->SDK 管理器 window 中,请确认已安装 Layout Inspector Image Server for API 29-30。

在此处输入图像描述

In case you still face the issue, take a look at the Run window and if you see a dlopen error for a library, add android:extractNativeLibs="true" in your AndroidManifest.xml file.如果您仍然遇到问题,请查看运行 window,如果您看到某个库出现 dlopen 错误,请在您的 AndroidManifest.xml 文件中添加 android:extractNativeLibs="true"。

Try to stop current running-app and run with debug mode again (click button "Debug" or press Shift F9) and select your process again.尝试停止当前正在运行的应用程序并再次以调试模式运行(单击“调试”按钮或按 Shift F9)并再次运行您的进程 select。 Please see some screenshots below:请看下面的一些截图:

  1. when error:错误时:在此处输入图像描述

  2. and after stop and run Debug again:停止并再次运行 Debug 后: 在此处输入图像描述

Try with adb shell settings delete global debug_view_attributes and adb shell settings delete global debug_view_attributes_application_package尝试使用adb shell settings delete global debug_view_attributesadb shell settings delete global debug_view_attributes_application_package 在此处输入图像描述

I hit on same issue.我遇到了同样的问题。 And above solutions doesn't work for me.以上解决方案对我不起作用。 It is resolved by reinstall the app重装app即可解决

Make sure android:hardwareAccelerated="false" isn't in your manifest file.确保android:hardwareAccelerated="false"不在您的清单文件中。

I can't see any updates in Layout Inspector in the new Android studio (4.0).我在新的 Android 工作室 (4.0) 中的 Layout Inspector 中看不到任何更新。

My app is targeting API 29, and build tools version is buildToolsVersion '29.0.3' .我的应用程序的目标是 API 29,构建工具版本是buildToolsVersion '29.0.3'

I'm running emulator Pixel_2_api_29 and my device MI A3 OS version 10 .我正在运行模拟器Pixel_2_api_29和我的设备MI A3 OS version 10

And this is all I can see这就是我能看到的全部布局检查器 android studio 4.0

Simply restarting Android Studio seems to solve the issue.只需重新启动 Android Studio 似乎即可解决问题。

If you are unable to view the Flutter Inspector and are seeing something like "Installing DevTools" on a Mac system.如果您无法查看 Flutter Inspector,并且在 Mac 系统上看到类似“Installing DevTools”的内容。 You have to add following environment variable.您必须添加以下环境变量。

  1. open ~/.bash_profile or open $HOME/.zshrc (depending upon your file system)打开~/.bash_profile或打开$HOME/.zshrc (取决于你的文件系统)
  2. Add:添加:
Hierarchy Viewer Variable

export ANDROID_HVPROTO=ddm

source ~/.bash_profile
  1. source ~/.bash_profile or source $HOME/.zshrc~/.bash_profile或源$HOME/.zshrc

For original answer click here: Credits对于原始答案,请单击此处: 学分

In some cases you can resolve this issue to connect device by name instead of connecting by ip.在某些情况下,您可以通过名称连接设备而不是通过 ip 连接来解决此问题。

It seems to be a different issue than what I see in your screenshot but maybe others have this issue, too.这似乎与我在您的屏幕截图中看到的问题不同,但也许其他人也有此问题。

One can sometime notice, the layout fetch seems to have finished but nothing is shown in the inspector.人们有时会注意到,布局获取似乎已经完成,但检查器中没有显示任何内容。 The reason then seems to be the graphical representation and not the inspector itself.原因似乎是图形表示而不是检查器本身。 So if you get something like this:所以如果你得到这样的东西:

在此处输入图像描述

where the zoom controls are visible but somehow no layout is appearing , try pressing the "Zoom to fit" button.在缩放控件可见但不知何故没有布局的地方,请尝试按“缩放以适合”按钮。 It then re-scales the view which leads to a redraw .然后重新缩放导致重绘的视图。 At least in my configuration for devices below API 29 (which have no "Live update") this is necessary in order to see something.至少在我对API 29 以下设备(没有“实时更新”)的配置中,这是看到某些东西所必需的。

在此处输入图像描述

try this: adb shell setenforce 0 (disable SELinex试试这个:adb shell setenforce 0(禁用 SELinex

In case just like me you stumble on this topic trying to code a Flutter app, I did not manage to make it work either.万一你像我一样在尝试编写 Flutter 应用程序时无意中发现了这个主题,我也没有设法让它工作。

Instead, you can use the Flutter Inspector which provides a minimal set of similar functionalities.相反,您可以使用 Flutter Inspector,它提供了一组最小的类似功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM