Why is hierarchyviewer not working for Samsung Galaxy TAB 7.0?
Asked Answered
C

8

71

I've used hierarachyviewer earlier, but on android emulator. It works absolutely fine when I use it on the emulator. However it does not work with Samsung Galaxy TAB 7.0, with Android 2.3.4.

This is the log, that I get

11:04:22 E/hierarchyviewer: Unable to get view server version from device 303599
64881B00EC
11:04:22 E/hierarchyviewer: Unable to get view server protocol version from devi
ce 30359964881B00EC
11:04:24 E/hierarchyviewer: Unable to debug device 30359964881B00EC
11:05:05 E/hierarchyviewer: Unable to get view server version from device 303599
64881B00EC
11:05:05 E/hierarchyviewer: Unable to get view server protocol version from devi
ce 30359964881B00EC
11:05:07 E/hierarchyviewer: Unable to debug device 30359964881B00EC
11:09:38 E/hierarchyviewer: Unable to get view server version from device 303599
64881B00EC
11:09:38 E/hierarchyviewer: Unable to get view server protocol version from devi
ce 30359964881B00EC
11:09:40 E/hierarchyviewer: Unable to debug device 30359964881B00EC

I'm also not using hierarchyviewer in the debug mode, just running the application. Thanks.

Candancecandela answered 18/5, 2012 at 5:44 Comment(2)
It seems that Samsung customized its android kernel a little too much! I got problems with GSM functions in Galaxy Tab as well.Greensand
possible duplicate of hierarchy is not working for my deviceUxorial
D
62

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...

Desireedesiri answered 11/10, 2012 at 10:8 Comment(3)
....if you are developing on a device that is NOT developer phone (ie...you bought it from a store or a carrier network) this is the way to go. Awesome.Mandymandych
Thanks. You only need too ViewServer.java to your project source and add few methods your code to enable ViewServer. Also add Internet Permission to your manifest.Greensand
If you have Base Activity class for all your Activities it will be very easy to implement.Desireedesiri
B
50

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).

Beaune answered 7/5, 2013 at 15:39 Comment(3)
Also available from DDMS perspective in Eclipse.Disjointed
That's not the same tool at all.Perceivable
Wow, this tool should be on all getting started docs for Android.Dissuasive
Z
35

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.)

Zhukov answered 18/5, 2012 at 5:52 Comment(1)
Thanks user1378730!! Maybe, I need to buy one. :)Candancecandela
L
21

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.

Lundgren answered 23/12, 2015 at 11:44 Comment(2)
Hi small silver, Please add ozodurkh's answer with a quotation if you think that is the solution. That will keep your valid even if that URL becomes invalid somedayCommittal
Hey how to do this? "Set the environment variable ANDROID_HVPROTO=ddm on your development machine."Edile
S
6

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

Slackjawed answered 18/5, 2012 at 5:54 Comment(1)
Thanks Srdjan!! Your answer was helpful. :)Candancecandela
A
4

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.

Annunciate answered 4/8, 2015 at 5:44 Comment(0)
C
1

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.

Conditional answered 30/10, 2016 at 8:51 Comment(0)
P
1

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.

Psalmody answered 13/10, 2018 at 9:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.