我正在使用 google-espresso 在 Kitkat 平台上测试系统应用程序联系人。我的测试项目位于#android-dir#/cts/tests/tests/contactTest。
这是.mk:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
# don't include this package in any target
LOCAL_MODULE_TAGS := optional
# and when built explicitly put it in the data partition
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
LOCAL_JAVA_LIBRARIES := android.test.runner
LOCAL_STATIC_JAVA_LIBRARIES += librarycontacts
LOCAL_CERTIFICATE := shared
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := contactsTest
LOCAL_INSTRUMENTATION_FOR := Contacts
include $(BUILD_CTS_PACKAGE)
##################################################
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += librarycontacts:libs/espresso-1.0-SNAPSHOT-bundled.jar
include $(BUILD_MULTI_PREBUILT)
这是 Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.contacts.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="19" />
<instrumentation
android:name="com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
android:targetPackage="com.android.contacts" />
<application>
<uses-library android:name="android.test.runner" />
</application>
</manifest>
这是命令:
> $ mmm cts/tests/tests/contactsTest/
> $ adb install -r out/target/product/generic/data/app/contactsTest.apk
> $ adb shell am instrument -w -r com.android.contacts.test/com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner
然后我收到了这个错误:
INSTRUMENTATION_RESULT: longMsg=java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
当我用eclipse编译和运行它时一切正常。它在这里失败了,我都尝试过espresso-dependencies
并espresso-standalone
遵循指南,但都不起作用。
这个问题真的把我搞砸了。我是新来的,任何回复表示赞赏。谢谢。