繁体   English   中英

使用符号ext:'aar'或@aar添加库不会导入传递依赖项

[英]Adding a library with the notation ext: 'aar' or @aar doesn't import the transitive dependencies

我通过将我的应用程序转换为库来标记应用程序,并且我有一个配置文件,该文件传递给库以更改颜色,添加新的加载动画,更改一些文本等。库具有上面列出的所有依赖项。 当我将库导入新应用程序时,由于新应用程序只是库的变体,因此除非我也导入这些依赖项,否则它将无法编译。

我添加了自定义库使用:

compile(group: 'com.lib.libcore', name: 'libcore', version: '1.0.35', ext: 'aar', classifier: '')

build.grdle ,它仍然强制我包含库中的所有依赖项。

我想知道是否有人知道为什么我需要在我的应用程序中包含我的自定义库中的所有依赖项。

所以我有这些依赖:

compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.5.0'
compile ('com.google.firebase:firebase-core:11.4.2')
compile ('com.google.firebase:firebase-messaging:11.4.2')
compile ('com.google.firebase:firebase-crash:11.4.2')
compile ('com.google.firebase:firebase-invites:11.4.2')
compile 'com.google.android.gms:play-services-location:11.4.2'
compile 'com.google.android.gms:play-services-gcm:11.4.2'
compile 'com.google.android.gms:play-services-maps:11.4.2'
compile 'com.google.android.gms:play-services-auth:11.4.2'
compile 'com.google.android.gms:play-services-places:11.4.2'

当我使用gradle导入库时,我还需要在app gradle文件中包含所有这些依赖项。 有没有人知道如何在没有应用程序失败的情况下将其从应用程序gradle中删除?

之所以会发生这种情况,是因为你使用了符号ext: 'aar'

 compile(group: 'com.lib.libcore', name: 'libcore', version: '1.0.35', ext: 'aar', classifier: '')

它是相同的:

compile('com.lib.libcore:libcore:1.0.35@aar')

你可以查看官方文件:

仅工件表示法创建模块依赖项,该依赖项仅下载具有指定扩展名的工件文件。 忽略现有模块描述符。

这意味着您只想下载aar工件,而不是依赖项。

只需删除依赖@aar中的符号ext: 'aar'@aar

如果要在项目中使用自定义库,则必须将其作为依赖项添加到build.gradle中 (模块:app)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM