How to make “Hierarchy Viewer” work in a real device?

六眼飞鱼酱① 提交于 2019-12-06 05:54:08

问题


I am new to android development I started using "Hierarchy Viewer"...it works fine with emulator that comes up with sdk.
The thing is I want to use this on a real device. I have made my research and found because of security reasons it works only on emulator and developers phone, from various sources.

Official Android Developer Site

But I also found that by using the "ViewServer.java" in our project, we can use this tool on real device.

GitHub romainguy / ViewServer Link:

What I understand is there are 2 things to be done...

  1. Include this ViewServer.java into our project

  2. Add the INTERNET permission in manifest.(<uses-permission android:name="android.permission.INTERNET"/>)

And while reading the comments in the java file, I also understood how to use addWindow method inside onCreate and stuffs.

But even after all these while trying to install this app into my device, eclipse "Invalid APK File!"...for both real device and emulator.

But normal apps works with emulator, but not the app added with this java file in it!!!

And someone kindly explain me if anything else needs to be done. Because the link I shared have so many other files and I am not sure what they are and how to use them. All I cared about is the "ViewServer.java" file in it.

If possible can someone explain me step by step on what are all needs to be done?


回答1:


ViewServer is required only on non-rooted devices with Android older than 4.1.

For devices with Android 4.1+ all you need is to set ANDROID_HVPROTO=ddm environmental variable and restart adb server.

It's one of the hidden Android features, found it on free Udacity course - Android Performance (Lesson 1: Render, 12th part "Hierarchy Viewer Walkthrough", links below video).




回答2:


Try using HierarchyViewerSupport Annotation but not sure how much it will be of help.

This @HierarchyViewerSupport annotation allows you to use the HierarchyViewer inspection tool on any device.

Make sure your application has INTERNET permission and android:debuggable = true Manifest.

Just annotate your activity with @HierarchyViewerSupport :

@HierarchyViewerSupport
 @EActivity
 public class MyActivity extends Activity {

 }

I am not sure dude how much this could help based on your question i did bit RnD, i think its not possible on production builds as reason you already explained.

Anyway if you want details of your current activity screen like info about widgets and all you can still get it using a Python Script as well which i have developed but again it does not work on production build.

Try this above solution and let us know if it helps.




回答3:


Have a look a the link following below it has detail information about how to enable hierarchy viewer in actual device

How to show hierarchy viewer in android device



来源:https://stackoverflow.com/questions/22400400/how-to-make-hierarchy-viewer-work-in-a-real-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!