我正在使用Eclipse Juno并使用Jython 2.7解释器创建PyDev项目,但我得到的Nulpointer异常如下所示
我的代码是
import re
import sys
import os
from com.android.monkeyrunner import MonkeyRunner
# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection()
错误如下
device = MonkeyRunner.waitForConnection()
at com.android.monkeyrunner.MonkeyRunner.waitForConnection(MonkeyRunner.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
java.lang.NullPointerException: java.lang.NullPointerException
然后我添加了AndroidViewClient,但它抛出了ImportError。我为AndroidViewClient设置了p ath。
import re
import sys
import os
try:
ANDROID_VIEW_CLIENT_HOME = os.environ['ANDROID_VIEW_CLIENT_HOME']
except KeyError:
print >>sys.stderr, "%s: ERROR: ANDROID_VIEW_CLIENT_HOME not set in environment" % __file__
sys.exit(1)
sys.path.append(ANDROID_VIEW_CLIENT_HOME + '/src')
from com.dtmilano.android.viewclient import ViewClient
from com.android.monkeyrunner import MonkeyRunner
# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection()
print "Success!"
有人可以帮我吗?欣赏这一点。