问题
Currently i'm writing a library for android that needs Volley to function. Currently, the Volley dependency is declared in both the dependencies block for the library and whatever app uses the library. What do I need to do so that my Library can pull in its needed dependencies itself, instead of having the implementing app also declaring the dependency?
回答1:
Gradle supports transitive dependencies.
For a local library, this works like this:
compile(project(:LIBRARY_NAME)) {
transitive=true
}
For remote libraries:
compile ('com.somepackage:LIBRARY_NAME:1.0.0'){
transitive=true //default, normally no need to specify explicitly
}
来源:https://stackoverflow.com/questions/36877345/how-to-include-a-dependency-inside-an-android-library