首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Android复制依赖项

Android复制依赖项
EN

Stack Overflow用户
提问于 2015-09-01 16:18:49
回答 3查看 3.7K关注 0票数 1

我试图将unmano滑动面板库添加到我的android项目中,当我试图运行该项目时,我会得到这个错误:

代码语言:javascript
复制
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException: 
Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' 
finished with non-zero exit value 2

这是我的依赖项列表:

代码语言:javascript
复制
dependencies {
    repositories {
        mavenCentral()
    }
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:recyclerview-v7:22.2.1'
    compile 'com.google.android.gms:play-services:7.5.0'
    compile 'com.google.android.gms:play-services-analytics:7.5.0'
    compile 'com.baoyz.pullrefreshlayout:library:1.0.1'
    compile fileTree(dir: 'libs', include: 'gson-*.jar')
    compile 'com.parse.bolts:bolts-android:1.2.1'
    compile fileTree(dir: 'libs', include: 'Parse-*.jar')
    compile 'com.fasterxml.jackson.core:jackson-core:2.4.2'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.0'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.4.2'
    compile 'com.sothree.slidinguppanel:library:3.1.1'
}

根据我在其他文章中的理解,有一个重复的文件导致了这个构建错误。有人能帮我明白我需要做些什么来解决这个问题吗?如何找到重复的文件?是否有任何gradle命令可用于检测和删除重复项?谢谢

编辑:这是我的lib文件夹内容:

代码语言:javascript
复制
bolts-android-1.2.1.jar
gson-2.3.1.jar
Parse-1.10.0.jar
YoutubeAndroidPlayerApi.jar
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2015-09-01 16:23:42

似乎你已经两次包含了同一个库文件

compile fileTree(dir: 'libs', include: ['*.jar'])

compile fileTree(dir: 'libs', include: 'gson-*.jar')

compile fileTree(dir: 'libs', include: 'Parse-*.jar')

因此,gson-*.jarParse-*.jar似乎包含了两次。

编辑:

正如您所说的,问题在于umano向上滑动库,那么它应该是它的依赖关系问题。

代码语言:javascript
复制
dependencies {
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.android.support:support-annotations:22.2.1'
    compile 'com.android.support:recyclerview-v7:22.2.1'
    compile 'com.nineoldandroids:library:2.4.0'
}

我检查了com.baoyz.pullrefreshlayout:library,它有以下的依赖项

代码语言:javascript
复制
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:21.0.0'
}

因此,您包含了两个版本的支持库,因此出现了问题。

代码语言:javascript
复制
compile 'com.baoyz.pullrefreshlayout:library:1.0.1'

若要解决此问题,请将上面的一行替换为下面的一行。

代码语言:javascript
复制
compile('com.baoyz.pullrefreshlayout:library:1.0.1') { 
{
    exclude group: 'com.android.support', module: 'support-v4'
}

除上述内容外,请按照下面的指南安装multidex

https://developer.android.com/tools/building/multidex.html

票数 4
EN

Stack Overflow用户

发布于 2015-09-01 16:26:57

你的第一个依赖

代码语言:javascript
复制
compile fileTree(dir: 'libs', include: ['*.jar'])

还有这些

代码语言:javascript
复制
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile fileTree(dir: 'libs', include: 'gson-*.jar')

编译相同的图书。首先,在libs文件夹中编译所有的jar文件,其中存储了gson和和Parse。另外两个又添加了gson和Parse库。

因此,简单地删除它们并添加类似的内容。

代码语言:javascript
复制
compile fileTree(dir: 'libs', include: ['*.jar'])    
......
compile files('libs/gson-*.jar')
compile files('libs/Parse-*.jar')

希望这能有所帮助。

票数 2
EN

Stack Overflow用户

发布于 2015-09-02 03:02:06

使multiDexEnabled在您的build.grade文件中在defaultConfig中变为真。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32336454

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档