添加带有符号 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 导入库时,我还需要在应用 gradle 文件中包含所有这些依赖项。有谁知道如何在应用程序失败的情况下将其从应用程序 gradle 中删除?
如果你想在你的项目中使用自定义库,你必须将它作为依赖项添加到你的 build.gradle (Module:app)
发生这种情况是因为您使用的是符号 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')
您可以查看 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
。
我通过将我的应用程序转换为库来为应用程序贴上白色标签,并且我有一个配置文件传递给库以更改颜色、添加新的加载动画、更改一些文本等。库有上面列出的所有这些依赖项。当我将库导入新应用程序时,由于新应用程序只是库的一个变体,除非我也导入这些依赖项,否则它不会编译。
我使用以下方法添加了自定义库:
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 中删除?
如果你想在你的项目中使用自定义库,你必须将它作为依赖项添加到你的 build.gradle (Module:app)
发生这种情况是因为您使用的是符号 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')
您可以查看 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
。