Unable to merge dex error when using Mockito as androidTestImplementation
See original GitHub issueAndroid Studio: 3.0 Gradle plugin: 3.0.0 Mockito: 2.11.0
I encounter the following issue when trying to use Mockito in instrumented unit tests (connectedAndroidTest
):
Error:Execution failed for task ‘:twinkle:transformDexArchiveWithExternalLibsDexMergerForDebugAndroidTest’. java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
I have the following test dependencies in build.gradle
:
testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:3.5.1'
testImplementation 'org.mockito:mockito-core:2.11.0'
androidTestImplementation 'com.android.support:support-annotations:27.0.0'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test:rules:1.0.1'
androidTestImplementation 'org.mockito:mockito-core:2.11.0'
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
Has anyone else had this issue? I have also included the linkedin dexmaker for mockito to attempt to remedy the issue, to no avail. Any help on this would be greatly appreciated!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:13 (2 by maintainers)
Top Results From Across the Web
Unable to merge dex with androidTestImplementation
I get an unable to merge dex exception when i try to run my android test together with uiAutomation. androidTestImplementation ...
Read more >NullPointerException on a project with mockito-android as ...
gradlew assembleAndroidTest` fails when `androidTestImplementation 'org.mockito:mockito-android:2.21.0'` is part of the app dependencies in build.gradle ...
Read more >Build Failed with an Exception – Unable to merge dex
What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. java.lang.RuntimeException: java.lang.
Read more >How to use Mockito together with MockK in Android ... - Medium
tl;dr: If you want to use both Mockito and MockK in the same Android instrumentation test, use this configuration: androidTestImplementation ...
Read more >Gradle tips and recipes - Android Developers
Target specific builds with dependency configurations ... You can use the sourceSets block in the module-level build.gradle file to change where Gradle ...
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
Just my two cents. In my case adding
multiDexEnabled true
worked, but I had to add it to all the modules which the application was made of, not only the application module.Paste this in app.gradle below defaultConfig{}.It worked for me
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }