Pit*_*tel 33 android android-gradle-plugin aar
我们正在为我们的API创建一些库,我们将使外部开发人员的生活更轻松.
因此,我们创建了新的库项目,并将Retrofit和其他一些库作为依赖项.
dependencies {
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.0.1'
compile 'com.squareup.retrofit2:converter-gson:2.0.1'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
}
Run Code Online (Sandbox Code Playgroud)
现在,当我们构建它时,它会生成aar文件.
但是现在当我们将aar文件放到libs目录并将其设置为依赖项时,我们仍然必须在用户的build.gradle文件中放置相同的依赖项,这很糟糕.它应该来自图书馆,对吧?
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile(name: 'ourlibrary', ext: 'aar') {
transitive = true;
}
}
Run Code Online (Sandbox Code Playgroud)
如何transitive = true上班?
Gab*_*tti 56
的AAR文件不包含嵌套(或传递)的依赖关系,并且不具有其描述库所使用的依赖关系的POM文件.
这意味着,如果要使用flatDirrepo 导入aar文件,则还必须在项目中指定依赖项.
在您的情况下transitive=true,由于上述原因,添加无法解决您的问题.
您应该使用maven存储库(您必须在私有或公共maven存储库中发布库),您将不会遇到相同的问题.
在这种情况下,gradle使用包含依赖项列表的pom文件下载依赖项.
| 归档时间: |
|
| 查看次数: |
7596 次 |
| 最近记录: |