java.lang.NoClassDefFoundError: org.mockito.internal.util.MockCreationValidator
See original GitHub issueExplanation:
Swapping out Google’s dexmaker with LinkedIn’s dexmaker, I am getting the following error. From what I can tell, the LinkedIn version of the dexmaker is so much larger that it causes the Android Test APK to become Multidex.
I have tried the following: https://stackoverflow.com/questions/30081386/how-to-put-specific-classes-into-main-dex-file and https://stackoverflow.com/questions/34310259/trying-to-test-an-android-module-in-multidex-app-com-android-test-runner-multid.
Any way to avoid this?
Error:
D/AndroidRuntime( 2960): Shutting down VM
E/AndroidRuntime( 2970): FATAL EXCEPTION: main
E/AndroidRuntime( 2970): Process: <>, PID: 2970
E/AndroidRuntime( 2970): java.lang.NoClassDefFoundError: org.mockito.internal.util.MockCreationValidator
E/AndroidRuntime( 2970): at org.mockito.internal.creation.MockSettingsImpl.validatedSettings(MockSettingsImpl.java:166)
E/AndroidRuntime( 2970): at org.mockito.internal.creation.MockSettingsImpl.confirm(MockSettingsImpl.java:162)
E/AndroidRuntime( 2970): at org.mockito.internal.MockitoCore.mock(MockitoCore.java:62)
E/AndroidRuntime( 2970): at org.mockito.Mockito.mock(Mockito.java:1637)
E/AndroidRuntime( 2970): at org.mockito.Mockito.mock(Mockito.java:1550)
...
E/AndroidRuntime( 2970): at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
...
E/AndroidRuntime( 2970): at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
...
E/AndroidRuntime( 2970): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
E/AndroidRuntime( 2970): at android.support.test.runner.MonitoringInstrumentation.callApplicationOnCreate(MonitoringInstrumentation.java:323)
E/AndroidRuntime( 2970): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4344)
E/AndroidRuntime( 2970): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
E/AndroidRuntime( 2970): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
E/AndroidRuntime( 2970): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 2970): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime( 2970): at android.app.ActivityThread.main(ActivityThread.java:5017)
E/AndroidRuntime( 2970): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2970): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime( 2970): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
E/AndroidRuntime( 2970): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
E/AndroidRuntime( 2970): at dalvik.system.NativeStart.main(Native Method)
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
java.lang.NoClassDefFoundError: org/objenesis/ObjenesisStd ...
ClassNotFoundException is result of a class loader that is not able to load a particular class. In your case Mockito has a transitive ......
Read more >mockito failure [Solved] (Testing forum at Coderanch)
java.lang.NoClassDefFoundError: org/objenesis/ObjenesisStd. at org.mockito.internal.creation.jmock.ClassImposterizer.<init>(ClassImposterizer.java: 36 ).
Read more >java.lang.NoClassDefFoundError: org.mockito.internal.util ...
Swapping out Google's dexmaker with LinkedIn's dexmaker, I am getting the following error. From what I can tell, the LinkedIn version of the...
Read more >org.mockito.internal.configuration.InjectingAnnotationEngine
I'm trying to get PowerMock 1.4 working with Mockito 1.8.1. I've tried the SystemClassUser example like package com.googlecode.janrain4j.internal.http;
Read more >NoClassDefFoundError on CI but works locally
java.lang.NoClassDefFoundError: Could not initialize class org.mockito.Answers at java.base/jdk.internal.reflect.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi.
@jaredsburrows, DexMaker has its own MockMaker, so I think that you can exclude Byte Buddy from your test apk.
@jaredsburrows,
Running
./gradlew androidDependencies
with the above code will get the following result.Byte Buddy is used for
MockMaker
of Mockito, so it is required for local unit testing. However, since DexMaker has its ownMockMaker
which does not rely on Byte Buddy, it can be excluded from dependencies scoped asandroidTestCompile
.FYI, Mockito does not support mock final on Android.
https://static.javadoc.io/org.mockito/mockito-core/2.8.9/org/mockito/Mockito.html#0.1
Because
inline mock maker
relies on thejava.lang.instrument
API which Android does not support.