Joyal  C  Joseph
Joyal C Joseph

Reputation: 288

More than one file was found with OS independent path 'mockito-extensions/org.mockito.plugins.MockMaker'

More than one file was found with OS independent path 'mockito-extensions/org.mockito.plugins.MockMaker' getting this error while adding androidTestImplementation "org.mockito:mockito-inline:2.15.0"

in gradle to mock final class

Upvotes: 12

Views: 6152

Answers (4)

Panos Gr
Panos Gr

Reputation: 677

If you are using Koin dependency injector, I found the solution on this Github issue.

Try androidTestImplementation ("org.koin:koin-test:$koin_version") { exclude group: 'org.mockito' }

It worked for me, I hope this may help others in the future.

Upvotes: 2

Zain
Zain

Reputation: 40878

In my case I resolved this issue by removing dexmaker dependency from the build.gradle

So, I removed the below dependency

androidTestImplementation "com.linkedin.dexmaker:dexmaker-mockito:2.12.1"

and kept only the below Mockito dependency

androidTestImplementation "org.mockito:mockito-android:2.25.0"

Not sure if that your case, but it solves mine.

Upvotes: 3

mpellegr
mpellegr

Reputation: 3182

The only correct answer is PowerMockito does not support the Davik VM Android uses, it is meant for a standard JVM. So you can't use it with instrumented tests, only unit tests. I have heard there's a library called OpenDex that allows you to use PowerMockito even with Android but it seems a bit involved to setup and I haven't personally tried it.

Upvotes: 0

aha
aha

Reputation: 3759

For Android, you usually just want

androidTestImplementation "org.mockito:mockito-android:<latest-version>"

You especially don't want mockito-inline because it configures the wrong MockMaker (mock-maker-inline) instead of AndroidByteBuddyMockMaker which is the only one working on Android that is distributed by the Mockito project. If you need advanced capabilities or faster mocking, head over to the dexmaker project.

Upvotes: 5

Related Questions