添加一个符号为ext的库:'aar'或@aar不会导入传递依赖项
问题描述:
我已将白色标记为应用程序,将应用程序转换为库,并且我有一个配置文件传递给库更改颜色,添加新的加载动画,更改一些文本等。库具有上面列出的所有依赖关系。当我将库导入新应用程序时,由于新应用程序只是库的一种变体,因此它将不会编译,除非我也导入这些依赖项。添加一个符号为ext的库:'aar'或@aar不会导入传递依赖项
我添加使用自定义库:
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这个导入库,我需要在应用程序文件的gradle所有这些依赖关系为好。有没有人知道我可以从应用程序gradle中删除它,而不会失败?
答
这是因为您正在使用的符号ext: 'aar'
compile(group: 'com.lib.libcore', name: 'libcore', version: '1.0.35', ext: 'aar', classifier: '')
这是同样的:
compile('com.lib.libcore:libcore:[email protected]')
您可以检查official doc:
An artifact only notation creates a module dependency which downloads only the artifact file with the specified extension. Existing module descriptors are ignored.
这意味着你想只下载AAR神器,并没有依赖关系。
只需删除依赖项中的符号ext: 'aar'
或@aar
即可。
你在说什么图书馆? – Raghunandan
@Raghunandan基本上我用白色标记了一个应用程序,将我的应用程序转换为一个库,并且我有一个配置文件传递给库以更改颜色,添加一个新的加载动画,更改一些文本等。库包含所有上面列出的那些依赖关系。当我将库导入新应用程序时,由于新应用程序只是库的一种变体,因此它将不会编译,除非我也导入这些依赖项。我试图找出如何不必两次导入依赖关系。 – Mikerizzo