如何在库模块中添加 .aar 依赖项? [英] How to add .aar dependency in library module?
问题描述
我有一个库模块的 .aar
文件.
我想将它用作我其他项目的库模块中的库或依赖项.
我该怎么做?
I am having one .aar
file of one library module.
I want to use it as a library or dependency in my other project's library module.
How do I do it?
我尝试了以下链接中提供的选项:
http://kevinpelgrims.com/blog/2014/05/18/reference-a-local-aar-in-your-android-project/
I tried options provided at below links:
http://kevinpelgrims.com/blog/2014/05/18/reference-a-local-aar-in-your-android-project/
仅当我在项目的应用程序模块中添加 .aar
引用时才有效.但不能在库模块中工作.
It works only if I add .aar
reference in my project's application module. But not working in library module.
谢谢.
推荐答案
按照这个设置,你将能够将 .aar
依赖添加到库模块
Follow this setting and you will able to add .aar
dependency to library module
build.gradle(项目:....)
allprojects {
repositories {
jcenter()
mavenCentral()
flatDir {
dirs 'libs'
dirs project(':library_module').file('libs')
}
}
}
build.gradle(模块:app)
dependencies {
...
compile project(':library_module')
}
build.gradle(模块:library_module)
dependencies {
...
compile(name:'aar_file_name', ext:'aar')
}
settings.gradle(项目设置)
include ':app', ':library_module'
这篇关于如何在库模块中添加 .aar 依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!