2013-04-28 50 views
1

我一直在玩AndroidViewClient一段時間,但我不明白爲什麼當運行dump.py示例時,此擴展名不會顯示視圖的ID。我的設備位於API lvl 16以上。可能是什麼問題?AndroidViewClient不顯示ID

我得到這樣的輸出,但同樣,我不知道爲什麼它不能告訴意見的名字......

android.widget.FrameLayout id/no_id/1 
    android.widget.LinearLayout id/no_id/2 
     android.widget.FrameLayout id/no_id/3 
     android.widget.RelativeLayout id/no_id/4 
      android.widget.Button id/no_id/5 New Jersey 
      android.widget.Button id/no_id/6 New York 
      android.widget.Button id/no_id/7 New Castle 
      android.widget.Button id/no_id/8 New Berg 
      android.widget.Button id/no_id/9 New Class 

錯誤:

C:\Users\EGHDK\android-sdk\tools>monkeyrunner C:\AndroidViewClient-master\Andro 
idViewClient-master\AndroidViewClient\examples\dump.py 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
] Script terminated due to an exception 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]Traceback (most recent call last): 
    File "C:\AndroidViewClient-master\AndroidViewClient-master\AndroidViewClient\e 
xamples\dump.py", line 87, in <module> 
    vc = ViewClient(*ViewClient.connectToDeviceOrExit(**kwargs1), **kwargs2) 
    File "C:\AndroidViewClient-master\AndroidViewClient-master\AndroidViewClient\s 
rc\com\dtmilano\android\viewclient.py", line 935, in __init__ 
    adb = ViewClient.__obtainAdbPath() 
    File "C:\AndroidViewClient-master\AndroidViewClient-master\AndroidViewClient\s 
rc\com\dtmilano\android\viewclient.py", line 1075, in _ViewClient__obtainAdbPath 

    raise Exception('adb="%s" is not executable. Did you forget to set ANDROID_H 
OME in the environment?' % adb) 
Exception: adb="adb.exe" is not executable. Did you forget to set ANDROID_HOME i 
n the environment? 

130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.PyException.doRaise(PyException.java:219) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.Py.makeException(Py.java:1159) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.Py.makeException(Py.java:1163) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.Py.makeException(Py.java:1167) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at com.dtmilano.android.viewclient$py._ViewClient__obtainAdbPath$56(C:\A 
ndroidViewClient-master\AndroidViewClient-master\AndroidViewClient\src\com\dtmil 
ano\android\viewclient.py:1075) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at com.dtmilano.android.viewclient$py.call_function(C:\AndroidViewClient 
-master\AndroidViewClient-master\AndroidViewClient\src\com\dtmilano\android\view 
client.py) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.PyTableCode.call(PyTableCode.java:165) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.PyBaseCode.call(PyBaseCode.java:117) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.PyFunction.__call__(PyFunction.java:307) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at com.dtmilano.android.viewclient$py.__init__$54(C:\AndroidViewClient-m 
aster\AndroidViewClient-master\AndroidViewClient\src\com\dtmilano\android\viewcl 
ient.py:1020) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at com.dtmilano.android.viewclient$py.call_function(C:\AndroidViewClient 
-master\AndroidViewClient-master\AndroidViewClient\src\com\dtmilano\android\view 
client.py) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.PyTableCode.call(PyTableCode.java:165) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.PyBaseCode.call(PyBaseCode.java:297) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.PyBaseCode.call(PyBaseCode.java:191) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.PyFunction.__call__(PyFunction.java:385) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.PyFunction.__call__(PyFunction.java:380) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.PyInstance.__init__(PyInstance.java:120) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.PyClass.__call__(PyClass.java:194) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.PyObject._callextra(PyObject.java:537) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.pycode._pyx0.f$0(C:\AndroidViewClient-master\AndroidViewCl 
ient-master\AndroidViewClient\examples\dump.py:89) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.pycode._pyx0.call_function(C:\AndroidViewClient-master\And 
roidViewClient-master\AndroidViewClient\examples\dump.py) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.PyTableCode.call(PyTableCode.java:165) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.PyCode.call(PyCode.java:18) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.Py.runCode(Py.java:1197) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.core.__builtin__.execfile_flags(__builtin__.java:538) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:156 
) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at com.android.monkeyrunner.ScriptRunner.run(ScriptRunner.java:116) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at com.android.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter. 
java:77) 
130428 20:11:28.636:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions 
]  at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter 
.java:189) 

回答

3

如果設備的API級別爲> = 16AndroidViewClient使用的默認後端是UiAutomator它不顯示ID。爲了提供額外的幫助,AndroidViewClient爲視圖分配了唯一的ID,這就是dump.py顯示在您的案例中。

androidviewclient activity diagram

可以通過提供相應的命令行選項來dump.py強制ViewServer後端:

$ dmup.py --force-view-server-use 

,你會得到視圖的ID。

+0

嗯...認爲會做的伎倆,但如果我添加強制查看服務器,它給了我一個錯誤。 – EGHDK 2013-04-28 07:09:13

+0

什麼是錯誤? – 2013-04-28 07:10:18

+0

更新了我的問題。注意:層次結構查看器工作。 – EGHDK 2013-04-28 07:10:30