How to include dependencies in android library gradle project?

纵饮孤独 提交于 2019-12-09 04:44:45

问题


I'm building an android library project with Gradle using Android Studio. It has some local dependencies:

compile project(':androidlibrary')

with nested, additional external dependencies:

compile group: 'com.google.guava', name: 'guava', version: '14.0.1'

I managed to build the aar file but no external or local dependencies are included. I expect external dependencies to be mentioned in the POM file when published to maven, but what about the local ones?

What is the right way to build such project?


回答1:


I ended up using "download library from maven" feature of Intellj IDEA as described here. It downloads the library and all it's dependencies to the local directory.

Just a friendly warning: including dependencies is considered a very bad practice at SHOULD BE AVOIDED. It may cause conflicts.




回答2:


There is no automated way to package the dependencies of the library inside the aar. This is contrary to proper dependency management and can lead to problems down the line.

If you really want to do this, you'd have to gather the dependencies manually (using code in build.gradle) and manually package the files in the aar.



来源:https://stackoverflow.com/questions/22478258/how-to-include-dependencies-in-android-library-gradle-project

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