0

代码很简单

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage
device = MonkeyRunner.waitForConnection()
device.touch(84, 712, "DOWN_AND_UP")

可以在模拟器和我的 SE Xperia Ray 上运行,

但是当我在另一台设备上运行时,市场上不卖。

错误信息弹出。

运行一些命令是可以的,例如,采取“snapShot”

但对于“触摸”“按”,总是失败。

对于某些设备来说,是不是一些monkeyruuner错误,它只是不起作用

或者问题出在设备上,可能修改后的设备源代码有问题。

我在互联网上搜索过,找不到解决方案,

我需要决定是否在设备上使用monkeyruuner,

所以,我需要一些帮助。

对不起我的英语不好 : )

错误日志是

121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] Error se
nding touch event: 84 712 DOWN_AND_UP
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice]java.net.
SocketException: Software caused connection abort: socket write error
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.
net.SocketOutputStream.socketWrite0(Native Method)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.
net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.
net.SocketOutputStream.write(SocketOutputStream.java:136)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.n
io.cs.StreamEncoder.writeBytes(StreamEncoder.java:202)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.n
io.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:272)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.n
io.cs.StreamEncoder.implFlush(StreamEncoder.java:276)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.n
io.cs.StreamEncoder.flush(StreamEncoder.java:122)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.
io.OutputStreamWriter.flush(OutputStreamWriter.java:212)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.
io.BufferedWriter.flush(BufferedWriter.java:236)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.chimpchat.ChimpManager.sendMonkeyEventAndGetResponse(ChimpManager.java:18
6)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.chimpchat.ChimpManager.sendMonkeyEvent(ChimpManager.java:234)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.chimpchat.ChimpManager.tap(ChimpManager.java:329)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.chimpchat.adb.AdbChimpDevice.touch(AdbChimpDevice.java:361)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.monkeyrunner.MonkeyDevice.touch(MonkeyDevice.java:136)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.r
eflect.NativeMethodAccessorImpl.invoke0(Native Method)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.r
eflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.r
eflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.
lang.reflect.Method.invoke(Method.java:597)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyReflectedFunction.__call__(PyReflectedFunction.java:175)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyObject.__call__(PyObject.java:355)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyMethod.__call__(PyMethod.java:215)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyMethod.instancemethod___call__(PyMethod.java:221)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyMethod.__call__(PyMethod.java:206)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyObject.__call__(PyObject.java:432)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyObject.__call__(PyObject.java:436)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.pycode._pyx0.f$0(d:\1234.py:18)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.pycode._pyx0.call_function(d:\1234.py)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyTableCode.call(PyTableCode.java:165)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyCode.call(PyCode.java:18)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.Py.runCode(Py.java:1197)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.__builtin__.execfile_flags(__builtin__.java:538)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.util.PythonInterpreter.execfile(PythonInterpreter.java:156)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.monkeyrunner.ScriptRunner.run(ScriptRunner.java:116)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.java:77)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:189)
4

1 回答 1

0

问题可能在于获取连接

device = MonkeyRunner.waitForConnection()

不幸的是 device is never ,因此要验证它,您可以使用与ViewClientNone相同的方法,使用此代码段

device = MonkeyRunner.waitForConnection()
try:
        device.wake()
except java.lang.NullPointerException, e:
        print >> sys.stderr, "%s: ERROR: Couldn't connect to %s: %s" % (progname, serialno, e)
        sys.exit(3)
于 2012-12-06T04:53:48.623 回答