5.23.0 is incompatible with mockk-android due to dispatcher.jar conflict
A sample app depending on both mockito-android:5.23.0 and mockk-android:1.14.11 (latest version at the time of writing) leads to a build time failure. This:
- prevents any Android project that is depending on both frameworks from being able to upgrade to 5.23.0
- prevents any mockito based Android project from adopting
mockk(mockk-android) alongside mockito
5.23.0 added the dispatcher.jar in #3792, as a result of the dependency on dexmaker.
Unfortunately MockK packages its own dispatcher.jar, which has different content as it includes its own impl, i.e. they're not interchangeable.
Mockito initially evaluated a similar solution (#3789) but ultimately went for depending directly on dexmaker.
The resulting build error is:
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 informationNote that both implementations are hardcoded with the dispatcher.jar filename
mockito 5.23.0: because it depends on dexmaker, which hardcodes the filename here
mockk 1.14.11: https://github.com/mockk/mockk/blob/v1.14.11/modules/mockk-agent-android/src/main/kotlin/io/mockk/proxy/android/AndroidMockKAgentFactory.kt#L204
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.
Mockito does not build its own dispatcher jar, as presented above, so modifying the filename would not be as easy.
Source: mockito/mockito