Run Hierarchy Viewer without using the Android emulator
The Android Hierarchy Viewer is a useful tool for optimizing your user interface. However for security purposes it can only be used on apps running in the Android emulator. This is a pain because the emulator is slow to start up and slow to load the app. Another headache is the flawed support for aspect ratios that emulate tablets. This results in crashes. Fortunately there is another way.
Using an Android virtual machine running locally allows the Hierarchy Viewer to connect and investigate your app. I installed the VirtualBox general-purpose full virtualizer for x86 hardware. After that I needed an Android VM so got the VMLite Android and followed the directions at that link. Once I did a “adb connect localhost” from a command line, I went into my Eclipse workspace and modified the Run configuration for my app. I temporarily set the Target tab to “Always prompt to pick device”. Once the prompt came up, I selected the VM instead of my physical tablet. The app installed and displayed very quickly.
Next, I had to get around the headache that has existed in the Hierarchy Viewer tool apparently since version 8 of the tools. The problem was that neither the colored performance indicators nor duration information appeared in any of the views. Using this “solution“, I got those key features to show up.
With the app running in the VM, the Hierarchy Viewer happily dug in and rounded up the performance data for me. This is a very viable alternative to using the Android emulator. I appreciate Ed Burnette for suggesting this approach and giving me the URL’s to VirtualBox and VMLite Android.