简体   繁体   English

如果依赖项在aar库中声明,我是否需要在应用程序的build.gradle中对同一库进行delcare?

[英]if the dependencies were declared in the aar library, do I need to delcare the same library in the build.gradle of the application?

as title, I declare the dependencies in the build.gradle of my module, and export the library into an aar file. 作为标题,我在模块的build.gradle中声明依赖项,然后将库导出到aar文件中。 however, when I integrate the aar into another android project(let's say project B), I have to declare the sample dependencies again in project B. 但是,当我将aar集成到另一个android项目(比如项目B)时,我必须在项目B中再次声明样本依赖项。


my question is "is there anyway to include all the libraries in the aar file, and in the project B, I can only include that aar library without any other dependencies?" 我的问题是 “无论如何在aar文件中包含所有库,并且在项目B中,我只能在没有任何其他依赖项的情况下包含该aar库?”


here is the dependency of my module library 这是我模块库的依赖

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.google.android.gms:play-services-vision:11.6.2'
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.rmtheis:tess-two:9.0.0'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.12'
    implementation 'com.android.support.constraint:constraint-layout:1.1.1'
}

but in my android project B, after the aar is included, I still need to add the other libraries. 但是在我的android项目B中,在包含aar之后,我仍然需要添加其他库。

here is the dependency of my android project B 这是我的Android项目B的依赖项

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.my.library:com.my.library@aar'
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.12'
    implementation 'com.google.android.gms:play-services-vision:11.6.2'
    implementation 'com.android.support.constraint:constraint-layout:1.1.1'
    implementation 'com.rmtheis:tess-two:9.0.0'
}

Can anyone help? 有人可以帮忙吗? thanks. 谢谢。

By default AARs do not include any dependencies. 默认情况下,AAR不包含任何依赖项。 If you want to include them you have to copy these libs from module into your package, either by doing it manually or this task might help you: https://stackoverflow.com/a/33539941/4310905 如果要包括它们,则必须通过手动执行将这些库从模块复制到软件包中,否则此任务可能会对您有所帮助: https : //stackoverflow.com/a/33539941/4310905

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

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