【发布时间】:2015-06-04 08:46:17
【问题描述】:
我有一个 SDK 项目,它在 gradle 中引用了很多依赖项。我必须要求 SDK 用户在他们的项目中使用 SDK 时添加这些依赖项。问题是,每次我添加一些新的依赖项或用新的依赖项替换当前依赖项时,我都必须要求用户也进行更改,我认为这不是一个好习惯.有没有办法捆绑.aar 中的所有依赖项。我正在使用以下代码生成工件文件。
uploadArchives{
repositories.mavenDeployer {
def deployPath = file(getProperty('aar.deployPath'))
repository(url: "file://${deployPath.absolutePath}")
pom.project {
groupId 'myPackageName'
artifactId 'wingoku-io'
version "0.0.6"
}
}
这些是我的依赖项:
dependencies {
compile 'com.github.nkzawa:socket.io-client:0.5.0'
compile 'com.android.support:cardview-v7:21.+'
compile 'de.greenrobot:eventbus:2.4.0'
}
编辑:
我在uploadArchives 方法中添加了以下方法。工件文件的大小增加了,但是当我在应用项目中使用 .aar 文件时,它找不到文件。
uploadArchives{
repositories.mavenDeployer {
def deployPath = file(getProperty('aar.deployPath'))
repository(url: "file://${deployPath.absolutePath}")
pom.project {
groupId 'myPackageName'
artifactId 'wingoku-io'
version "0.0.6"
}
**configurations.all {
transitive = true
}**
}
更新:
我尝试了以下代码,因为@aar 正在生成错误(在 jcenter() 上找不到 xx.xx.xx.aar)。这仍然失败,d
compile ('com.github.nkzawa:socket.io-client:0.5.0'){
transitive=true
}
compile ('com.android.support:cardview-v7:21.+@aar'){
transitive=true
}
compile ('de.greenrobot:eventbus:2.4.0'){
transitive=true
}
Dalvik 为所有类抛出以下警告:
dalvikvm﹕类 'Lio/wingoku/sdk/Fetch$6;' 的链接失败
它最终会抛出异常ClassDefNotFound
【问题讨论】:
-
你能发布你的依赖部分吗?
-
@ben75 请查看更新后的问题。
-
仔细查看日志以查看另一个警告,抱怨同一库的多个版本。 (也许支持库?)
-
不,我找不到关于同一个库的多个版本的任何警告。我也使用了你的依赖模块。仍然抛出 ClassDefNotFoundError。
-
你是怎么解决的?
标签: maven android-studio gradle artifacts