5

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?

Barnee
  • 3,212
  • 8
  • 41
  • 53
Legendary Genius
  • 310
  • 3
  • 20

3 Answers3

6

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

Fenix Voltres
  • 3,448
  • 1
  • 29
  • 36
3

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.

  • Please refer to http://stackoverflow.com/questions/13244374/how-can-i-get-all-component-and-widget-id-of-current-android-window-screen-progr/14394852#14394852 , just in case if you want some ready made solution for fetching widget info of a activity screen using python. –  Mar 14 '14 at 09:46
  • Sorry it din't solve the issue, still I can at least give you a vote up for your suggestions... – Legendary Genius Mar 14 '14 at 09:51
  • I chatted with one of the Legend of Android Developer, See what he has to say... Pawan Arya 15:23 is it possible to fetch activity screen data from production build devices Vinayak Wagh 15:24 no Pawan Arya 15:24 Sure Vinayak Wagh 15:24 yup for that u hav to be in that application context only Pawan Arya 15:25 okes,, no other way out right Vinayak Wagh 15:25 nahi Pawan Arya 15:25 ok thanks bro Its not possible until you have access to Application Context of App. –  Mar 14 '14 at 09:56
  • I Chatted with my friend on Companies link portal and its not possible to chat on stack overflow since its blocked @ my office... :) –  Mar 14 '14 at 10:01
  • This worked on my 5.0 device when setting `ANDROID_HVPROTO` did not. – Matthew Read Mar 04 '16 at 20:38
1

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

rana_sadam
  • 1,216
  • 10
  • 18