Android Gradle DexException: Multiple dex files define Lorg/hamcrest/Description

I solved the error by looking in Android Studio for the exact class called ‘Description’. It turned out to be present in 3 jars. One from junit, one from a direct dependency and one from mockito.

enter image description here

It turns out that junit, instead of a normal dependency, includes the Hamcrest classes in the junit jar.

enter image description here

To be able to solve the problem include junit-dep instead of junit.

so change

androidTestCompile(‘junit:junit:4.8.+’)

to

androidTestCompile(‘junit:junit-dep:4.8.+’)

Mockito has the same problem/solution: use mockito-core.1.9.5.jar instead of mockito-all.1.9.5.jar

Leave a Comment