使用 Parse 和 Multidex 复制条目
Duplicate entry using Parse and Multidex
我的项目是一个使用 Parse 的聊天应用程序。添加其他依赖后,开始出现这个问题:
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-oracle/bin/java'' finished with non-zero exit value 2
在 Whosebug 中搜索,一些人告诉我这可能是 Android 的 65K 限制。
所以,为了解决我遵循以下步骤:
1 - 添加 Multidex
DefaultConfig {
multiDexEnabled true
}
和
compile 'com.android.support:multidex:1.0.0'
https://developer.android.com/tools/building/multidex.html
2 - 在 Android Gradle 设置中启用 Jumbo 模式
dexOptions {
jumboMode = true
}
我清理了项目并 运行 gradle 构建。它没有产生任何错误。伟大的!但是当我单击 "Run app" 时,它会在下面生成此错误。
Error: Execution failed for task ': app:
packageAllDebugClassesForMultiDex'. > Java.util.zip.ZipException:
duplicate entry: bolts / AggregateException.class
如果我删除依赖项 'com.parse.bolts: bolts-android: 1. +',"Run app" 可以工作,但我离不开 Parse 的依赖项。
这是我的 Gradle 构建脚本:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "br.com.triangulum.mink"
minSdkVersion 18
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
jumboMode = true
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.parse.bolts:bolts-android:1.+'
compile('com.android.support:multidex:1.0.0') {
exclude group: 'com.parse.bolts',
module: 'bolts-android'
}
androidTestCompile 'com.android.support:multidex-instrumentation:1.0.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs', include: 'Parse*.jar')
compile project('libraries:httprequest')
compile project('libraries:cameralibrary')
compile project('libraries:bgarefreshlayout')
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:cardview-v7:+'
compile 'com.android.support:palette-v7:+'
compile 'com.android.support:design:+'
compile 'com.daimajia.swipelayout:library:1.2.0@aar'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.google.code.gson:gson:2.2.+'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.afollestad:material-dialogs:0.7.4.0'
compile 'com.getbase:floatingactionbutton:1.10.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'de.greenrobot:eventbus:2.4.+'
compile'com.edmodo:cropper:1.0.+'
compile 'com.github.ksoichiro:android-observablescrollview:+'
compile 'com.etsy.android.grid:library:1.0.5'
compile('com.mikepenz:actionitembadge:3.0.2@aar') {
transitive = true
}
compile 'com.daimajia.swipelayout:library:1.2.0@aar'
compile 'com.android.support:multidex:1.0.+'
}
尝试改变这个:
compile('com.android.support:multidex:1.0.0') {
exclude group: 'com.parse.bolts',
module: 'bolts-android'
}
为此:
compile('com.android.support:multidex:1.0.0');
粗体模块有时用于修复重复的 dexLibs
此致
您的 com.facebook.android:facebook-android-sdk:4.1.0
库与解析混淆,因为两者在内部使用相同的 bolts-android 模块并且具有该模块的不同版本。尝试从任何解析或 facebook gradle 依赖项中排除此模块。
compile('com.facebook.android:facebook-android-sdk:4.1.0') {
exclude group: 'com.parse.bolts',
module: 'bolts-android'
}
我遇到了同样的问题,当我在终端旁 运行 ./gradlew yourModuleName:dependencies
时,我准确地发现了哪两个库在内部混淆了同一模块的不同版本。
我的项目是一个使用 Parse 的聊天应用程序。添加其他依赖后,开始出现这个问题:
Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-oracle/bin/java'' finished with non-zero exit value 2
在 Whosebug 中搜索,一些人告诉我这可能是 Android 的 65K 限制。 所以,为了解决我遵循以下步骤:
1 - 添加 Multidex
DefaultConfig {
multiDexEnabled true
}
和
compile 'com.android.support:multidex:1.0.0'
https://developer.android.com/tools/building/multidex.html
2 - 在 Android Gradle 设置中启用 Jumbo 模式
dexOptions {
jumboMode = true
}
我清理了项目并 运行 gradle 构建。它没有产生任何错误。伟大的!但是当我单击 "Run app" 时,它会在下面生成此错误。
Error: Execution failed for task ': app: packageAllDebugClassesForMultiDex'. > Java.util.zip.ZipException: duplicate entry: bolts / AggregateException.class
如果我删除依赖项 'com.parse.bolts: bolts-android: 1. +',"Run app" 可以工作,但我离不开 Parse 的依赖项。
这是我的 Gradle 构建脚本:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "br.com.triangulum.mink"
minSdkVersion 18
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
jumboMode = true
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.parse.bolts:bolts-android:1.+'
compile('com.android.support:multidex:1.0.0') {
exclude group: 'com.parse.bolts',
module: 'bolts-android'
}
androidTestCompile 'com.android.support:multidex-instrumentation:1.0.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs', include: 'Parse*.jar')
compile project('libraries:httprequest')
compile project('libraries:cameralibrary')
compile project('libraries:bgarefreshlayout')
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:cardview-v7:+'
compile 'com.android.support:palette-v7:+'
compile 'com.android.support:design:+'
compile 'com.daimajia.swipelayout:library:1.2.0@aar'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.google.code.gson:gson:2.2.+'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.afollestad:material-dialogs:0.7.4.0'
compile 'com.getbase:floatingactionbutton:1.10.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'de.greenrobot:eventbus:2.4.+'
compile'com.edmodo:cropper:1.0.+'
compile 'com.github.ksoichiro:android-observablescrollview:+'
compile 'com.etsy.android.grid:library:1.0.5'
compile('com.mikepenz:actionitembadge:3.0.2@aar') {
transitive = true
}
compile 'com.daimajia.swipelayout:library:1.2.0@aar'
compile 'com.android.support:multidex:1.0.+'
}
尝试改变这个:
compile('com.android.support:multidex:1.0.0') {
exclude group: 'com.parse.bolts',
module: 'bolts-android'
}
为此:
compile('com.android.support:multidex:1.0.0');
粗体模块有时用于修复重复的 dexLibs
此致
您的 com.facebook.android:facebook-android-sdk:4.1.0
库与解析混淆,因为两者在内部使用相同的 bolts-android 模块并且具有该模块的不同版本。尝试从任何解析或 facebook gradle 依赖项中排除此模块。
compile('com.facebook.android:facebook-android-sdk:4.1.0') {
exclude group: 'com.parse.bolts',
module: 'bolts-android'
}
我遇到了同样的问题,当我在终端旁 运行 ./gradlew yourModuleName:dependencies
时,我准确地发现了哪两个库在内部混淆了同一模块的不同版本。