How to include a dependency inside an Android library?

有些话、适合烂在心里 提交于 2020-01-03 02:01:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!