将aar包括到aar中 [英] Include aar into aar

查看:110
本文介绍了将aar包括到aar中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个以aar格式分发的android库.它重300kb.我想创建另一个库,并且也要以aar格式创建,其中第一个库是依赖项.但是结果库的权重为30kb,因此显然不包括第一个库.

I have an android library distributed in aar format. It weight 300kb. I want to create another library and also in aar format, where first library in dependencies. But result library weight is 30kb, so obviously it does not not include first library.

我尝试使用 flatDir 添加第一个库:

I tried to add first library using flatDir:

repositories {
    flatDir {
        dirs 'libs'
    }
}
dependencies {
    compile(name:'mylib-1.0', ext:'aar')
}

并使用 maven-publish 发布到mavenLocal:

And publish to mavenLocal using maven-publish:

repositories {
    mavenLocal()
}
dependencies {
    compile 'com.mylib:mylib:1.0.0@aar'
}

但仍然不包括结果aar.

but still it does not include to result aar.

如何将我的第一个aar包含在结果aar中?

How to include my first aar to result aar?

推荐答案

实现它的最好方法是使用 maven 回购分发aar.

The best way to achieve it is to distribute the aar with a maven repo.

aar 文件不包含传递依赖项,并且没有描述该库使用的依赖项的pom文件.
这意味着,如果要使用 flatDir 存储库导入aar文件,则还必须在项目中指定依赖项.

The aar file doesn't contain the 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.

使用 Maven存储库,您不会遇到相同的问题.
在这种情况下,gradle使用pom文件下载依赖项,该文件将包含依赖项列表.

Using a maven repository you will not have the same issue.
In this case, gradle downloads the dependencies using the pom file which will contains the dependencies list.

这篇关于将aar包括到aar中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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