Layout Inspector not always available?


I am running Android Studio 2.3.3, and I have noticed that the Layout Inspector button in the Android Monitor tool is not always available (appears grayed out sometimes) when I am running the application in the simulator or in the actual hardware.

The only way I know to get it back is to restart Android Studio, but that’s a big hammer solution… Anyone know what could be causing it to not become available and possibly how to fix it for good or at least how to get it back without having to restart studio?

If you’re using the Android Emulator, you can skip this section. Otherwise, you need to set up your device as follows.

Note: Your device must be running Android 4.1 or higher.

Enable Developer Options on your device.
Set the environment variable ANDROID_HVPROTO=ddm on your development machine.
This variable tells Hierarchy Viewer to connect to the device using the ddm protocol, which is the same as the DDMS protocol. The caveat is that there can be only one process on the host that connects to the device, so you must kill any other DDMS session to run Hierarchy Viewer.
Start Hierarchy Viewer

Figure 1. Android Device Monitor

Connect your device to your computer. If prompted by a dialog on the device that asks, Allow USB debugging?, tap OK.
Open your project in Android Studio, build and run it on your device.
Select Tools > Android > Android Device Monitor. Android Studio might show a Disable adb integration dialog because only one process can connect to the device via adb at once, and Android Device Monitor is requesting a connection. So click Yes.
Figure 1 illustrates what initially appears in the Android Device Monitor.
In the menu bar, select Window > Open Perspective, and then click Hierarchy View.
You should see an arrangement similar to what’s shown in figure 2. If not, select Window > Reset Perspective to return to the default layout.
Double-click your app’s package name in the Windows tab on the left. This populates the panes with the view hierarchy of your app.
Get familiar with the tools

Figure 2. Hierarchy Viewer panes.

The Hierarchy Viewer provides the following panes (as shown in figure 2):

Tree View (center): Shows a tree view of your view hierarchy. You can drag and zoom the tree using your mouse and the zoom control at the bottom. Each node indicates it’s View class name and ID name.
Tree Overview (top right): Gives you a bird’s-eye view of your app’s complete view hierarchy. Move the grey rectangle to change the viewport that’s visible in the Tree View.
Layout View (bottom right): Shows a wireframe view of your layout. The outline of the currently selected view is red, and its parent view is light red.
Clicking a view here also selects it in the Tree View, and vice versa.

Ethan Stark

Hi Ethan,

Thank you for your useful info. I also found the details in the following link.


“Set the environment variable ANDROID_HVPROTO=ddm on your development machine” is a key point for this challenge.

The Environment Variables can be set based on the following link.


In my case with Mac,

  1. open ~/.bash_profile
  2. Add:
    #Hierarchy Viewer Variable
    export ANDROID_HVPROTO=ddm
  3. source ~/.bash_profile