skip to Main Content

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


  1. You can try using the Gradle strictly constraint when declaring the transitive dependency.

    For example:

    implementation 'org.apache.httpcomponents:httpclient:4.5.4'
    implementation('commons-codec:commons-codec') {
       version {
         strictly '1.9'
       }
    }
    
    

    Here commons-code is an internal dependency of httpclient, by adding strictly constraint to commons-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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search