How to include a dependency inside an Android libr

2019-06-07 02:03发布

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条回答
ゆ 、 Hurt°
2楼-- · 2019-06-07 02:56

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
}
查看更多
登录 后发表回答