Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoClassDefFoundError when updating from mockito 2.9.0 to 2.10.0

I am getting the following error when updating from mockito 2.9.0 to 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)

Anyone else getting this? Happening on an android project

like image 714
ligi Avatar asked Sep 11 '17 17:09

ligi


1 Answers

Try using mockito-android instead of DexMaker (which doesn't seem to be working anymore for Android instrumentation tests on Mockito 2.10 and higher):

compile "org.mockito:mockito-android:2.11.0"
like image 146
fast3r Avatar answered Oct 14 '22 15:10

fast3r