在Android中创建具有依赖项的库 [英] Create a library with dependencies in android

查看:72
本文介绍了在Android中创建具有依赖项的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个库'LibA',该库依赖于许多第三方库,例如RecyclerView,EventBus等.当我尝试将它作为aar包含在另一个项目中时,库被成功包含,但是依赖项没有出现在aar中./p>

第1季度,我如何在LibA中包括依赖项,以便当其他项目包含该库时,它不必担心我的库的内部依赖项.

第二季度> gradle如何管理库的依赖关系,一次下载所有依赖关系或首先检查主项目中已经存在的所有依赖关系?

第三季度当某人包括来自jcenter的库时,是否会带来所有依赖关系?

任何帮助将不胜感激.:)

解决方案

aar 文件不包含嵌套的(或 解决方案

The aar file doesn't contain the nested (or transitive) dependencies and doesn't have a pom file which describes the dependencies used by the library.

It means that, if you are importing a aar file using a flatDir repo you have to specify the dependencies also in your project.

Q1 How can I include dependencies in LibA, so that when some other project includes this library, it should not worry about internal dependencies of my library.

You should use a maven repository (you have to publish the library in a private or public maven repo), you will not have the same issue.
In this case, gradle downloads the dependencies using the pom file which will contains the dependencies list.

Q2 How does gradle manages dependencies of libraries, does it downloads all depenedencies at once, or first checks which are already available in the main project?

Gradle handles the dependencies for you. It doesn't add the same dependency twice or more.

Q3 When someone includes a library from jcenter, does that brings all the dependencies with it?

As said before, in this case the dependency has a pom file which describes all the nested dependencies. Gradle downloads it automatically.

这篇关于在Android中创建具有依赖项的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆