ddms - Android Debug Monitor hierarchy view not showing -


i trying connect app in adm unfortunately hierarchy view not showing. how should connect app adm tool?

device: nexus 4

os: 4.3.3

error:

    [2014-02-06 13:00:14 - hierarchyviewer]missing forwarded port 021df5e049116bac     [2014-02-06 13:00:14 - hierarchyviewer]unable view server version device     021df5e049116bac     [2014-02-06 13:00:14 - hierarchyviewer]missing forwarded port 021df5e049116bac     [2014-02-06 13:00:14 - hierarchyviewer]unable view server protocol version device 021df5e049116bac     [2014-02-06 13:00:14 - viewserverdevice]unable debug device: lge-nexus_4-021df5e049116bac 

refer profile layout hierarchy viewer hierarchy viewer usage.

today use hierarchy viewer app, , similar issue on both silulator , real device, hierarch viewer tree view window black.

note: newer version of android studio, can open hierarchy viewer tools > android > android device monitor > window > open perspective... > hierarchy view

enter image description here

below i'll show how solve problem on silulator , real device.

info: device debug mode on, don't test if has influence on below result.

a). check if device have open view server

bogon:~ roofe$ adb shell service call window 3 result: parcel(00000000 00000000   '........') 

note: if

cannot find command adb

adb in path of sdk, mine @ /users/roofe/library/android/sdk/platform-tools/adb. can add path or make alias it.

i put alias adb='/users/roofe/library/android/sdk/platform-tools/adb' in .bash_profile under user path, source ./.bash_profile. here adb command should works.

output info:

view server off: result: parcel(00000000 00000000 '........')

view server on: result: parcel(00000000 00000001 '........')

if view server on, hierarchy viewer should works well. , needn't read below.

unfortunately, if view server off, go on. both view server of simulator , read device off.

b). start view server

bogon:~ roofe$ adb shell service call window 1 i32 4939 result: parcel(00000000 00000001   '........') 

if result result: parcel(00000000 00000001 '........'), view server has been started. while if result result: parcel(00000000 00000000 '........'), view server cannot started.

you can shutdown view server

adb shell service call window 2 i32 4939 

here execute command 2 times shutdown it, maybe there execution time here.

bogon:~ roofe$ adb shell service call window 2 i32 4939 result: parcel(00000000 00000001   '........') bogon:~ roofe$ adb shell service call window 2 i32 4939 result: parcel(00000000 00000000   '........') 

most of real device cannot start view server. security, android on real device have restrict on this. can find relative code in file windowmanageservice.java source code of andorid

if (!checkcallingpermission(manifest.permission.dump, "startviewserver")) {     return false; }  

so if you're genius cracker, can root device remove restrict. i've not make it. if try successfull, show me it. i'll appreciated on smart work.

here simulator works. while real device not. if view server still off, go on.

c). using ddm protocol, 1 method doc of android studio doc profile layout hierarchy viewer

if you're using android emulator, can skip section. otherwise, need set device follows.

note: device must running android 4.1 or higher.

enable developer options on device.

set environment variable android_hvproto=ddm on development machine.

this variable tells hierarchy viewer connect device using ddm protocol, same ddms protocol. caveat there can 1 process on host connects device, must kill other ddms session run hierarchy viewer.

add export android_hvproto=ddm .bash_profile source ./.bash_profile.

remove installed app, , restart android studio, install app , can hierarchy view now.

note: set ddm without restart android studio a, cannot hierarchy view it. 1 day later, realise it, , test. founds after set ppm, it's better restart android studio. guess when android studio start read config, can cache it.

i didn't test without uninstall app.

d). set view server

please don't fell frustrated here. start view server easy.

tool: viewserver on github

add build.gradle

allprojects {     repositories {         jcenter()         maven {url "https://jitpack.io"}     } } dependencies {       ...     compile 'com.github.romainguy:viewserver:017c01cd512cac3ec054d9eee05fc48c5a9d2de'   }   

add internet permission in manifest file

<uses-permission android:name="android.permission.internet" /> 

then regiester viewserver activity want inspect

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);     } } 

by now, can run hierarchy view on real device.

enter image description here


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -