2013-08-21 101 views
0

问题:MonkeyDevice getViewIdList()抛出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 ... 

事我没有解决:

  • 更新SDK至最新版本(SDK工具在22.0.5在18.0.1 SDK平台工具)
  • 4.2.2相同的异常和4.3模拟器

我已经江郎才尽了测试和做一些谷歌搜索什么都没有。有任何想法吗?

回答

1

这实际上是因为

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) 
+0

辉煌,谢谢! – CatShoes

相关问题