Android 重复的依赖项
Android Duplicate Dependencies
我正在尝试将 unmano 向上滑动面板库添加到我的 android 项目,但当我尝试 运行 项目时出现此错误:
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
这是我的依赖项列表:
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 文件夹内容:
bolts-android-1.2.1.jar
gson-2.3.1.jar
Parse-1.10.0.jar
YoutubeAndroidPlayerApi.jar
您似乎包含了两次相同的库文件
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs', include: 'gson-*.jar')
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
看来gson-*.jar
和Parse-*.jar
被包含了两次
编辑:
按照你说的是umano上滑库的问题,那么应该是依赖的问题
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
,它有以下依赖关系
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.0.0'
}
所以您包含了 2 个版本的支持库,因此出现了问题。
compile 'com.baoyz.pullrefreshlayout:library:1.0.1'
要解决此问题,请将上面的行替换为下面的行。
compile('com.baoyz.pullrefreshlayout:library:1.0.1') {
{
exclude group: 'com.android.support', module: 'support-v4'
}
除上述之外,请按照以下指南设置 multidex
你的第一个依赖项
compile fileTree(dir: 'libs', include: ['*.jar'])
还有这些
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile fileTree(dir: 'libs', include: 'gson-*.jar')
编译相同的库。第一个编译存储 gson 和 Parse 的 libs 文件夹中的所有 jar 文件。
而另外两个再次添加了gson和Parse库。
删除它们并添加类似这样的内容非常简单。
compile fileTree(dir: 'libs', include: ['*.jar'])
......
compile files('libs/gson-*.jar')
compile files('libs/Parse-*.jar')
希望对您有所帮助。
在 build.grade 文件中将 multiDexEnabled
设置为真,在 defaultConfig
.
中
我正在尝试将 unmano 向上滑动面板库添加到我的 android 项目,但当我尝试 运行 项目时出现此错误:
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
这是我的依赖项列表:
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 文件夹内容:
bolts-android-1.2.1.jar
gson-2.3.1.jar
Parse-1.10.0.jar
YoutubeAndroidPlayerApi.jar
您似乎包含了两次相同的库文件
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs', include: 'gson-*.jar')
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
看来gson-*.jar
和Parse-*.jar
被包含了两次
编辑:
按照你说的是umano上滑库的问题,那么应该是依赖的问题
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
,它有以下依赖关系
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.0.0'
}
所以您包含了 2 个版本的支持库,因此出现了问题。
compile 'com.baoyz.pullrefreshlayout:library:1.0.1'
要解决此问题,请将上面的行替换为下面的行。
compile('com.baoyz.pullrefreshlayout:library:1.0.1') {
{
exclude group: 'com.android.support', module: 'support-v4'
}
除上述之外,请按照以下指南设置 multidex
你的第一个依赖项
compile fileTree(dir: 'libs', include: ['*.jar'])
还有这些
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile fileTree(dir: 'libs', include: 'gson-*.jar')
编译相同的库。第一个编译存储 gson 和 Parse 的 libs 文件夹中的所有 jar 文件。 而另外两个再次添加了gson和Parse库。
删除它们并添加类似这样的内容非常简单。
compile fileTree(dir: 'libs', include: ['*.jar'])
......
compile files('libs/gson-*.jar')
compile files('libs/Parse-*.jar')
希望对您有所帮助。
在 build.grade 文件中将 multiDexEnabled
设置为真,在 defaultConfig
.