Some Noob Student Some Noob Student - 2 months ago 27
Java Question

How to get Powermock to work with Dexmaker

I am trying to incorporate Powermock as a dependency for my Android tests using the following build.gradle configuration:

compile ''
androidTestCompile('org.powermock:powermock-module-junit4:1.5.5') {
exclude module: 'junit'
androidTestCompile('org.powermock:powermock-api-mockito:1.5.5') {
exclude module: 'mockito-all'

However, the compiler is complaining that

Error:Gradle: Execution failed for task ':app:packageDebugTest'.
> Duplicate files copied in APK mockito-extensions/org.mockito.plugins.MockMaker
File 1: ~/.gradle/caches/modules-2/files-2.1/
File 2: ~/.gradle/caches/modules-2/files-2.1/

Looking into the jar structure, I noticed that both Dexmaker and Powermock declare a


What is a MockMaker? How do they differ?
And the most important question: Is it possible to get Powermock to work nicely with Dexmaker?

Thanks in advance. Any help would be greatly appreciated.


MockMaker is a glue module that integrates dexmaker with Mockito. It does what's necessary for Mockito to generate concrete classes with Dalvik .dex files instead of JVM .class files.

It's possible that Powermock will work with Dexmaker, but it's unlikely advanced Powermock features will work. In particular, Powermock advertises this:

PowerMock uses a custom classloader and bytecode manipulation to enable mocking of static methods, constructors, final classes and methods, private methods, removal of static initializers and more.

That custom class loader is unlikely to work on dalvikvm.