Gradle's conflict resolution doesn't work with Android projects?

I'm trying to compile a module whose dependency tree looks like

+--- com.squareup.burst:burst-junit4:1.0.2
|    +--- com.squareup.burst:burst:1.0.2
|    \--- junit:junit:4.11 -> 4.12
|         \--- org.hamcrest:hamcrest-core:1.3
|    +--- com.squareup:javawriter:2.1.1
|    +--- org.hamcrest:hamcrest-integration:1.1
|    |    \--- org.hamcrest:hamcrest-core:1.1 -> 1.3
|    +--- org.hamcrest:hamcrest-library:1.1
|    |    \--- org.hamcrest:hamcrest-core:1.1 -> 1.3
|    +---
|    +---
|    |    \--- junit:junit-dep:4.10
|    |         \--- org.hamcrest:hamcrest-core:1.1 -> 1.3
|    +---
|    +--- javax.annotation:javax.annotation-api:1.2
|    \--- org.hamcrest:hamcrest-core:1.1 -> 1.3

As you can see there's a hamcrest-core version conflict, but gradle appears to recognize the conflict and apply its default "latest version" strategy, which is exactly what I want.

However, when trying to run assembleDebugTest (either manually or through Android Studio) I get Multiple dex files define Lorg/hamcrest/MatcherAssert;

Some answers to similar questions suggest excludeing the unwanted jars, but I've encountered a bunch of similar conflicts, and it's getting a bit out of hand.

Why isn't gradle's default conflict strategy removing the older jar automatically? Does the android gradle plugin suppress that functionality?


After some more digging, it seems the issue is that my dependency tree contained hamcrest-core 1.3 and hamcrest-integration 1.1, and MatcherAssert was moved from hamcrest-integration to hamcrest-core between those versions.

So gradle was performing conflict resolution as documented; there was just a conflict between distinct modules which I didn't expect.

Forcing 1.3 for all three hamcrest modules took care of the problem.

Need Your Help

Sorting custom class array-list string using Collections.sort

java android sorting collections arraylist

I am trying to sort my custom class array-list using Collections.sort by declaring my own anonymous comparator. But the sort is not working as expected.

Making top window inaccessible in wx.python

python user-interface wxpython frame

How can I make top frame inaccessible while child frame is open?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.