Why is hierarchyviewer not working for Samsung Galaxy TAB 7.0?

瘦欲@ 提交于 2019-11-29 19:04:41
neworld

I found a workaround: https://github.com/romainguy/ViewServer

ViewServer is a simple class you can use in your Android application to use the HierarchyViewer inspection tool...

If you do need this library then follow these directions:

  • Include the ViewServer library(easy directions found here)
  • Your application must require the INTERNET permission
  • The recommended way to use this API is to register activities when they are created, and to unregister them when they get destroyed:

    public class MyActivity extends Activity {
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            // Set content view, etc.
            ViewServer.get(this).addWindow(this);
        }
    
        public void onDestroy() {
            super.onDestroy();
            ViewServer.get(this).removeWindow(this);
        }
    
        public void onResume() {
            super.onResume();
            ViewServer.get(this).setFocusedWindow(this);
        }
    }
    

Please refer to the documentation in ViewServer.java for more info...

Use the monitor-tool instead (android-sdk/tools/monitor).

Connect to your device. Close Eclipse first if you can't connect.

Press the "Dump view hierarchy for UI automator" button in the devices-tab. Its the one next to the screen-capture button.

Works since API Level 16 (Android 4.1).

You can only use HierarachyViewer on the emulator and special developer phones bought from google.

http://groups.google.com/group/android-developers/browse_thread/thread/b0b0af7a316ca768

Quote from above link

HierarchyViewer does not work on user builds (i.e. with devices available in stores.) This is for security reasons. If HiearchyViewer was able to work on user builds, any application on your desktop (or even on the phone in some cases) could potentially get access to private information (like logins and passwords.)

I'm solved question in max os

this ANDROID_HVPROTO solution is documented here:

http://developer.android.com/tools/performance/hierarchy-viewer/setup.html

then try to close Android Studio

run adb kill-server, adb start-server

and launch monitor work to me!

the answer is :

https://github.com/romainguy/ViewServer/issues/14#issuecomment-75354479

@ozodrukh's answer is usefull.

Almost no general-production phones will allow the HierarchyViewer to access them. Usually developer phones and emulators are the only ones with those features.

Similar issue i was having on 4.1 Android phone.Use ViewServer in your code.

Before checking in Hierarchy viewer,Just restart adb server once by doing.

the official documentation:Optimizing Your UI said so:

To preserve security, Hierarchy Viewer can only connect to devices running a developer version of the Android system.

Profile your layout with Hierarchy Viewer:

Set the environment variable

ANDROID_HVPROTO=ddm

So from [andrid-sdk]/tools folder run this in Command Line:

set ANDROID_HVPROTO=ddm
hierarchyviewer

Or put set ANDROID_HVPROTO=ddm in the hierarchyviewer.bat.

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