Android: how to resolve library dependency conflict

I am developing an Android library. There is little addiction in the library. I'm not sure what will happen if the developer uses my library with other dependencies already present in my Library. I tried to take a walk about this, but could not find anything.

For example, I use the Volley version X library in my library and send it as a gradle package. And the developer imports Volley with version Y along with my library.

What should be the best way to include dependency in a library (module, jar or package) in order to minimize a conflict situation.

+6
source share
2 answers

Two options

  • Possible ways to include the dependencies of your dependencies in them is to create a jar of fat / uber / share (there are Gradle plugins for this). Use the custom classloader to load cans in the can using One-Jar . Or use the Jar Jar Links .
  • The second option is to specify to exclude transitive dependencies :

    compile('X') { exclude module: 'Y' } 
+2
source

You specify the user to exclude other libraries. Example from my gradle

 compile('com.mobprofs:retrofit-simplexmlconverter:1.1') { exclude module: 'stax' exclude module: 'stax-api' exclude module: 'xpp3' } 

In general, the user will have conflicts, and he will know how gradle works, he will be able to add eclude libs

0
source

Source: https://habr.com/ru/post/988981/


All Articles