when I run hierarchy in terminal. it can show the interface of it, but can not connect to my device.And it can connect to virtual emulator. It remind me in terminal like that,
How can it show my view structure of my device in the hierarchy viewer. Can anyone help me ?or anyone who knows where to find the knowledge of the hierarchy. thanks in advance.
HierarchyViewer doesn't work on production builds for security reasons. I wrote an API that lets you use HierarchyViewer on any device with your app: https://github.com/romainguy/ViewServer
For anyone working with Android 4.1 or later: you can get Hierarchy Viewer working by setting the environment variable ANDROID_HVPROTO
to ddm
.
Mac OSX/Android Studio users, remember to start hierarchy viewer from command line so it will pick up the environment variable. If you installed it with Android Studio, you can find it in /Users/<user>/Library/Android/sdk/tools
https://developer.android.com/tools/performance/hierarchy-viewer/setup.html
Romain's ViewServer project (see answer #1) works great for this. I downloaded the code, turned the project into a library project, added a dependency in my app to the new library project, and changed my app's base Activity class to subclass from this simple class:
public class SimpleViewServerActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ViewServer.get(this).addWindow(this);
}
@Override
protected void onDestroy() {
super.onDestroy();
ViewServer.get(this).removeWindow(this);
}
@Override
protected void onResume() {
super.onResume();
ViewServer.get(this).setFocusedWindow(this);
}
}
Now I can connect from the Android Debug Monitor's Hierarchy View and debug my layout.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With