[英]MonkeyDevice getViewIdList() throws NullPointerException
问题:MonkeyDevice getViewIdList()引发NullPointerException
我如何得到错误:
# Retyped, not copied, excuse typos.
$ monkeyrunner
>>> from com.android.monkeyrunner import MonkeyDevice, MonkeyRunner
>>> device = MonkeyRunner.waitForConnection()
>>> device.getViewIdList()
引发带有以下回溯的java.lang.NullPointerException
:
at com.android.chimpchat.ChimpManager.parseResponseforExtra(ChimpManager.java:216)
at com.android.chimpchat.ChimpManager.listViewIds(ChimpManager.java:392)
at com.android.chimpchat.adb.AdbChimpDevice.getViewIdList(AdbChimpDevice.java:604)
at com.android.monkeyrunner.MonkeyDevice.getViewIdList(MonkeyDevice.java:383)
... # Reflection stuff ...
我要解决的事情:
我没有足够的想法来进行测试,并且进行一些Google搜索都没有结果。 有任何想法吗?
这实际上是因为
device = MonkeyRunner.waitForConnection()
即使连接不成功,也不会返回错误或异常。
您可以使用与AndroidViewClient / culebra相同的技术来检测在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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.