上
我在更新Mockito 2.9.0到2.10.0时会遇到以下错误:
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/mockito/internal/invocation/realmethod/RealMethod;
at com.android.dx.mockito.DexmakerMockMaker.createMock(DexmakerMockMaker.java:43)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:51)
at org.mockito.Mockito.mock(Mockito.java:1798)
at org.mockito.Mockito.mock(Mockito.java:1711)
at org.ligi.passandroid.TestApp$createKodein$1$2.invoke(TestApp.kt:28)
at org.ligi.passandroid.TestApp$createKodein$1$2.invoke(TestApp.kt:21)
at com.github.salomonbrys.kodein.bindings.ASingleton.getInstance(bindings.kt:71)
at com.github.salomonbrys.kodein.bindings.NoArgBinding$DefaultImpls.getInstance(Binding.kt:186)
at com.github.salomonbrys.kodein.bindings.ASingleton.getInstance(bindings.kt:65)
at com.github.salomonbrys.kodein.bindings.ASingleton.getInstance(bindings.kt:65)
at com.github.salomonbrys.kodein.internal.KodeinContainerImpl$_transformBinding$1.invoke(KodeinContainerImpl.kt:129)
at com.github.salomonbrys.kodein.KodeinContainer$providerOrNull$1.invoke(KodeinContainer.kt:63)
at com.github.salomonbrys.kodein.Kodein$DefaultImpls.Instance(Kodein.kt:396)
at com.github.salomonbrys.kodein.internal.KodeinImpl.Instance(KodeinImpl.kt:13)
at org.ligi.passandroid.App.onCreate(App.kt:68)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
at android.support.test.runner.MonitoringInstrumentation.callApplicationOnCreate(MonitoringInstrumentation.java:382)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5403)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.mockito.internal.invocation.realmethod.RealMethod" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/org.ligi.passandroid.test-1/base.apk", zip file "/data/app/org.ligi.passandroid-1/base.apk"],nativeLibraryDirectories=[/data/app/org.ligi.passandroid.test-1/lib/x86, /data/app/org.ligi.passandroid-1/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
其他人得到这个吗?发生在Android项目
尝试使用mockito-android
代替dexmaker(似乎不再适用于Mockito 2.10及更高的Android仪器测试):
compile "org.mockito:mockito-android:2.11.0"