如何我船一个Android库(AAR)与远程的依赖关系(摇篮)? [英] How do I ship an Android Library (aar) with remote dependencies (gradle)?
问题描述
我试图建立与摇篮,有远程相关性的AAR文件。一个例子构建脚本如下。正如你可以看到我有两个相关性。我遇到的问题是,当我做了发布,AAR文件不包含远程依赖关系,所以当我有在其他项目中AAR文件,我得到NoClassDefFound错误。
我发现,如果我从我的本地Maven回购复制的jar到libs文件夹在我的项目,然后将罐子不会获取包含在发布AAR。我怎样包括在AAR文件中的远程相关性?我在其他地方也阅读它的不好的做法,船依赖这样的,所以如果有一个更好的办法做到我想要做的,我为这一切的东西。
buildscript {
库{
mavenCentral()
}
依赖{
类路径com.android.tools.build:gradle:0.9.+
}
}
应用插件:机器人库
库{
mavenCentral()
mavenLocal()
}
安卓{
...为简洁起见省略
}
依赖{
编译com.somepackage:someartifact:1.0
编译com.anotherpackage:神器:2.0
}
请尝试使用传递
属性:
编译(GROUP_ID:artifact_id:VERSION_NAME @ AAR'){
传递=真
}
I am trying to build an aar file with gradle that has remote dependencies. An example build script is below. As you can see I have two dependencies. The problem I'm having is when I do a release, the aar file does not contain the remote dependencies, so when I include the aar file in other projects I get NoClassDefFound errors.
I found that if I copy the jar from my local maven repo to a libs folder in my project, then the jar does get included in the release aar. How do I include the remote dependencies in the aar file? I've also read elsewhere that it's bad practice to ship dependencies like this, so if there's a better way to do what I'm trying to do I'm all for it.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android-library'
repositories {
mavenCentral()
mavenLocal()
}
android {
... omitted for brevity
}
dependencies {
compile 'com.somepackage:someartifact:1.0'
compile 'com.anotherpackage:artifact:2.0'
}
try using the transitive
attribute:
compile ('group_id:artifact_id:version_name@aar'){
transitive = true
}
这篇关于如何我船一个Android库(AAR)与远程的依赖关系(摇篮)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!