You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Proposal: integrate dexmaker-mockito-inline for modern Android support #3788
Unfortunately, the mockito-android mockmaker is not very useful in the modern Android ecosystem. It relies entirely on the subclass mockmaker, so it cannot mock final classes. The Android ecosystem has become increasingly Kotlin centric - both Google's first-party libraries and app code. In Kotlin all classes are final by default unless explicitly marked with open keyword. This means mockito-android is not able to mock much at all.
For a long time our Android teams have been using https://github.com/linkedin/dexmaker with dexmaker-mockito-inline to support Mockito in Android tests. It has a mockmaker that does special bytecode generation for Dalvik.
A downside of dexmaker-mockito-inline for a while was that it only supported Android P (API 28) and up, but according to Android Studio's version distribution dialog this accounts for > 95% of distribution. It doesn't seem like much of a limitation at this point.
I'd like to replace mockito-android's mock maker implementation with one built on top of dexmaker. Any concerns about this?
dexmaker has an Apache 2.0 license so I think it would be okay to include its source. Maybe a better option would be to explicitly take a dependency or discuss transferring ownership?
I think this is a fair suggestion. The module lifes on the side anyways, so as long as we provide it, it can cater to the majority of users. People who want to support older Android versions can simply rely on older versions of Mockito. What do you think @mockito/developers
hi @jselbo the new dependency on dexmaker seems to cause an incompatibility between mockito-android and mockk-android, is that known?
2 files found with path 'dispatcher.jar' from inputs:
- io.mockk:mockk-agent-android:1.14.11/classes.jar
- com.linkedin.dexmaker:dexmaker-mockito-inline:2.28.6/classes.jar
Adding a packaging block may help, please refer to
https://developer.android.com/reference/tools/gradle-api/com/android/build/api/dsl/Packaging
for more information
Unfortunately MockK packages its owndispatcher.jar, so it's not even the same content, i.e. you can't just pick any of the two to keep in the final artifact
At first look I'm tempted to say this would be easily fixed by MockK renaming the jar to clarify it's mockk's version, but I was wondering if there's anything that can be done on this side of the fence
I wasn't aware of the issue before but that makes sense. Do you mind filing a separate issue?
We can probably fix like you said on the Mockito side by just renaming the jar.
As a temporary workaround I wonder if you could do some Gradle hacking to repackage the .aar renaming the dispatcher.jar . Or just wait to upgrade until we can publish a fixed version
Activity
raphw commentedon Feb 6, 2026
I think this is a fair suggestion. The module lifes on the side anyways, so as long as we provide it, it can cater to the majority of users. People who want to support older Android versions can simply rely on older versions of Mockito. What do you think @mockito/developers
Replace mockito-android ByteBuddy mock maker with dexmaker-mockito-in…
Replace mockito-android ByteBuddy mock maker with dexmaker-mockito-in…
jselbo commentedon Mar 13, 2026
Closed by #3792
faenil commentedon Sep 9, 2026
hi @jselbo the new dependency on dexmaker seems to cause an incompatibility between
mockito-androidandmockk-android, is that known?Unfortunately MockK packages its own
dispatcher.jar, so it's not even the same content, i.e. you can't just pick any of the two to keep in the final artifactAt first look I'm tempted to say this would be easily fixed by MockK renaming the jar to clarify it's mockk's version, but I was wondering if there's anything that can be done on this side of the fence
jselbo commentedon Sep 9, 2026
I wasn't aware of the issue before but that makes sense. Do you mind filing a separate issue?
We can probably fix like you said on the Mockito side by just renaming the jar.
As a temporary workaround I wonder if you could do some Gradle hacking to repackage the .aar renaming the dispatcher.jar . Or just wait to upgrade until we can publish a fixed version
bric3 commentedon Sep 10, 2026
Also, maybe open a new issue on mockito so folk can track this.