java.lang.NoClassDefFoundError:无法解决以下问题:Lorg / junit / runner / Description;

时间:2019-02-22 23:56:26

标签: android android-gradle build.gradle android-espresso gradle-plugin

我将库项目更改为我的主应用程序的模块。更改为模块后,我的浓缩咖啡测试失败,并显示以下错误

java.lang.NoClassDefFoundError: Failed resolution of: Lorg/junit/runner/Description;
    at android.support.test.internal.runner.listener.InstrumentationResultPrinter.<init>(SourceFile:109)
    at android.support.test.runner.AndroidJUnitRunner.<init>(SourceFile:266)
    at java.lang.Class.newInstance(Native Method)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5676)
    at android.app.ActivityThread.-wrap1(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6494)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
 Caused by: java.lang.ClassNotFoundException: Didn't find class "org.junit.runner.Description" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/data/app/com.app.test-uSvqB8Undvjs6AlTZlI2yQ==/base.apk", zip file "/data/app/com.app.debug-a7W2wcL11uDsXGYT79p-Ug==/base.apk"],nativeLibraryDirectories=[/data/app/com.app.test-uSvqB8Undvjs6AlTZlI2yQ==/lib/x86, /data/app/com.app.debug-a7W2wcL11uDsXGYT79p-Ug==/lib/x86, /data/app/com.app.test-uSvqB8Undvjs6AlTZlI2yQ==/base.apk!/lib/x86, /data/app/com.app.debug-a7W2wcL11uDsXGYT79p-Ug==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at android.support.test.internal.runner.listener.InstrumentationResultPrinter.<init>(SourceFile:109) 
    at android.support.test.runner.AndroidJUnitRunner.<init>(SourceFile:266) 
    at com.app.runner.CustomJUnitTestRunner.<init>(SourceFile:9) 
    at java.lang.Class.newInstance(Native Method) 
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5676) 
    at android.app.ActivityThread.-wrap1(Unknown Source:0) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656) 
    at android.os.Handler.dispatchMessage(Handler.java:106) 
    at android.os.Looper.loop(Looper.java:164) 
    at android.app.ActivityThread.main(ActivityThread.java:6494) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 

我的构建属性如下

ANDROID_BUILD_MIN_SDK_VERSION=23
ANDROID_BUILD_TARGET_SDK_VERSION=26
ANDROID_BUILD_SDK_VERSION=26
ANDROID_BUILD_TOOLS_VERSION=27.0.2

我的gradle插件版本为com.android.tools.build:gradle:3.0.1

0 个答案:

没有答案