我尝试使用AndroidViewClient进行自动化。在[github] [1]上有一个关于"安全模式"的页面。它说明了这一点:
AndroidViewClient有两个可能的后端:
UiAutomator适用于Android API 16及更高版本,因此如果您的设备具有以前版本,则唯一的选择是ViewServer。
我试图运行dump.py,但我得到了"设备是安全的"错误。安全模式页面指出"您唯一的选择是ViewServer"。什么是viewServer以及如何将它与monkeyrunner一起使用?
我很难抓住这个,因为根据github页面上的这个图片,如果我没有API lvl 16或更高,我可以使用id名称,如果我有它们(我我不知道该怎么做。
总之,
我有API级别15及更低级别的设备,以及源代码,我想使用viewID自动化我的应用程序。 这可能吗?
C:\Users\EGHDK\android-sdk\tools>monkeyrunner C:\AndroidViewClient-master\Andro
idViewClient-master\AndroidViewClient\examples\dump.py --ignore-secure-device --
do-not-start-view-server
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] Script terminated due to an exception
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
]Traceback (most recent call last):
File "C:\AndroidViewClient-master\AndroidViewClient-master\AndroidViewClient\e
xamples\dump.py", line 79, in <module>
ViewClient(*ViewClient.connectToDeviceOrExit(**kwargs1), **kwargs2).traverse
(transform=transform)
File "C:\AndroidViewClient-master\AndroidViewClient-master\AndroidViewClient\s
rc\com\dtmilano\android\viewclient.py", line 991, in __init__
subprocess.check_call([adb, '-s', self.serialno, 'forward', 'tcp:%d' % self.
localPort,
File "C:\Users\EGHDK\android-sdk\tools\lib\jython.jar\Lib\subprocess.py", lin
e 469, in check_call
File "C:\Users\EGHDK\android-sdk\tools\lib\jython.jar\Lib\subprocess.py", lin
e 456, in call
File "C:\Users\EGHDK\android-sdk\tools\lib\jython.jar\Lib\subprocess.py", lin
e 755, in __init__
File "C:\Users\EGHDK\android-sdk\tools\lib\jython.jar\Lib\subprocess.py", lin
e 1269, in _execute_child
OSError: Cannot run program "C:\Windows\system32\adb.exe" (in directory "C:\User
s\EGHDK\android-sdk\tools"): CreateProcess error=2, The system cannot find the
file specified
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyException.doRaise(PyException.java:219)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.Py.makeException(Py.java:1159)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.Py.makeException(Py.java:1163)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.Py.makeException(Py.java:1167)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at subprocess$py._execute_child$36(C:\Users\EGHDK\android-sdk\tools\lib
\jython.jar\Lib\subprocess.py:1270)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at subprocess$py.call_function(C:\Users\EGHDK\android-sdk\tools\lib\jyt
hon.jar\Lib\subprocess.py)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyTableCode.call(PyTableCode.java:165)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyBaseCode.call(PyBaseCode.java:297)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyBaseCode.call(PyBaseCode.java:191)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyFunction.__call__(PyFunction.java:385)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyMethod.__call__(PyMethod.java:215)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:221)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyMethod.__call__(PyMethod.java:206)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyObject.__call__(PyObject.java:367)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyObject.__call__(PyObject.java:371)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at subprocess$py.__init__$19(C:\Users\EGHDK\android-sdk\tools\lib\jytho
n.jar\Lib\subprocess.py:844)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at subprocess$py.call_function(C:\Users\EGHDK\android-sdk\tools\lib\jyt
hon.jar\Lib\subprocess.py)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyTableCode.call(PyTableCode.java:165)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyBaseCode.call(PyBaseCode.java:297)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyBaseCode.call(PyBaseCode.java:191)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyFunction.__call__(PyFunction.java:385)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyMethod.__call__(PyMethod.java:215)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:221)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyMethod.__call__(PyMethod.java:206)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyObjectDerived.dispatch__init__(PyObjectDerived.java
:1097)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyType.invoke_new_(PyType.java:444)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyType.type___call__(PyType.java:1374)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyType.__call__(PyType.java:1365)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyObject._callextra(PyObject.java:537)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at subprocess$py.call$7(C:\Users\EGHDK\android-sdk\tools\lib\jython.jar
\Lib\subprocess.py:456)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at subprocess$py.call_function(C:\Users\EGHDK\android-sdk\tools\lib\jyt
hon.jar\Lib\subprocess.py)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyTableCode.call(PyTableCode.java:165)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyBaseCode.call(PyBaseCode.java:297)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyFunction.__call__(PyFunction.java:370)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyFunction.function___call__(PyFunction.java:375)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyFunction.__call__(PyFunction.java:365)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyObject._callextra(PyObject.java:537)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at subprocess$py.check_call$8(C:\Users\EGHDK\android-sdk\tools\lib\jyth
on.jar\Lib\subprocess.py:475)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at subprocess$py.call_function(C:\Users\EGHDK\android-sdk\tools\lib\jyt
hon.jar\Lib\subprocess.py)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyTableCode.call(PyTableCode.java:165)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyBaseCode.call(PyBaseCode.java:297)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyBaseCode.call(PyBaseCode.java:124)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyFunction.__call__(PyFunction.java:317)
130425 14:05:23.047: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:995)
130425 14:05:23.047: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)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyTableCode.call(PyTableCode.java:165)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyBaseCode.call(PyBaseCode.java:297)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyBaseCode.call(PyBaseCode.java:191)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyFunction.__call__(PyFunction.java:385)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyFunction.__call__(PyFunction.java:380)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyInstance.__init__(PyInstance.java:120)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyClass.__call__(PyClass.java:194)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyObject._callextra(PyObject.java:537)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.pycode._pyx0.f$0(C:\AndroidViewClient-master\AndroidViewCl
ient-master\AndroidViewClient\examples\dump.py:79)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.pycode._pyx0.call_function(C:\AndroidViewClient-master\And
roidViewClient-master\AndroidViewClient\examples\dump.py)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyTableCode.call(PyTableCode.java:165)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyCode.call(PyCode.java:18)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.Py.runCode(Py.java:1197)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.__builtin__.execfile_flags(__builtin__.java:538)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:156
)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at com.android.monkeyrunner.ScriptRunner.run(ScriptRunner.java:116)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at com.android.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.
java:77)
130425 14:05:23.047:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter
.java:189)
答案 0 :(得分:1)
如果您的设备 API 级别为&lt; 16 您的替代方案(如image所示):
LocalViewServer 功能 LocalViewServerActivity ,您可以对其进行扩展,以简化您的活动中的 ViewServer 实施。
检查TemperatureConverterActivity上的示例源代码。
您发布错误的原因似乎是:
OSError: Cannot run program "C:\Windows\system32\adb.exe" (in directory "C:\User
s\EGHDK\android-sdk\tools"): CreateProcess error=2, The system cannot find the
file specified
您应该正确设置环境变量ANDROID_HOME以指向Android SDK安装。