I am facing an issue with the automatic updgrade of transitive dependencies by gradle(6.7.1).
Consider two parent dependencies A and B, both use different versions of PICASSO as transitive dependendency
A -> com.squareup.picasso:picasso:2.5.2
B -> com.squareup.picasso:picasso:2.71828
When builiding the android project , PICASSO is getting upgraded to 2.71828 automatically for both.
Since PICASSO API INITIALISATION is different for those 2 versions (2.5.2 and 2.71828) ,
A happens to throw NoSuchMethodException .
How can i enforce gradle to use specific PICASSO versions for A and B .
Any help would be much appreciated.
2
Answers
You can try using the Gradle
strictly
constraint when declaring the transitive dependency.For example:
Here
commons-code
is an internal dependency ofhttpclient
, by addingstrictly
constraint tocommons-code
,httpclient
will be forced to use version 1.9 regardless of what is defined internally in its project.You can find more details here
But let’s say that in your case, dependency B is incompatible with an older version of Picasso, then you can extract one of the dependencies to a separate module and make the transitive dependency strict there.
Then you can either try adding the new module and see if it works or create the jar of the second dependency and add it to your project such that Gradle won’t run conflict resolution in the first place
You can use
strictly
, for more you can refer below linkhttps://docs.gradle.org/current/userguide/dependency_downgrade_and_exclude.html#sec:enforcing_dependency_version