4

My project is a Chat app that uses Parse. After added other dependencies, this problem started appearing:

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

Searching here in StackOverflow, some folks told me that it could be the 65K limit from Android. So, to solve I followed the steps below:

1 - Add Multidex

DefaultConfig {
         multiDexEnabled true
}

and

compile 'com.android.support:multidex:1.0.0'

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

2 - Enable Jumbo Mode in Android Gradle Settings

 dexOptions {
        jumboMode = true
 }

I cleaned the project and ran the gradle build. It did not generate any errors. Great! But when I click "Run app" it generates this error below.

Error: Execution failed for task ': app: packageAllDebugClassesForMultiDex'. > Java.util.zip.ZipException: duplicate entry: bolts / AggregateException.class

If I remove the dependency 'com.parse.bolts: bolts-android: 1. +' the "Run app" works, but I can not do without the dependency of Parse.

This is my Gradle build script:

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.+'
}
rici
  • 234,347
  • 28
  • 237
  • 341
André Dantas
  • 163
  • 1
  • 13
  • Seems like the bolts-android library is being added twice. See my answer here for how to print your app's dependencies: http://stackoverflow.com/a/32049088/1233652. grep the output for 'bolts-android' to find duplicates. If you don't find duplicates there, look for manually added libraries under 'libs' folder (see if one of the jars contains it). – Alex Lipov Aug 21 '15 at 15:51
  • try to remove the line when you exclude com.android.bolts – Max Pinto Aug 22 '15 at 02:01
  • @MaxPinto yeah, its work. Thanks – André Dantas Aug 24 '15 at 20:18
  • Good to heard and see that works, will add the answer, to end the Thread of converstaion, if you want accept to close it. Regards – Max Pinto Aug 24 '15 at 20:40

2 Answers2

3

try to change this:

compile('com.android.support:multidex:1.0.0') {
        exclude group: 'com.parse.bolts',
                module: 'bolts-android'
    }

To this:

compile('com.android.support:multidex:1.0.0');

the bolds module is used sometimes to fix Duplicated dexLibs

Regards

Max Pinto
  • 1,463
  • 3
  • 16
  • 29
  • 4
    Now they split `bolts-android` into `bolts-applinks` and `bolts-tasks`. Now you have to exclude bolts-tasks module: `compile ('com.parse:parse-android:1.11.0') { exclude group: 'com.parse.bolts', module: 'bolts-tasks'; }` – Yaroslav Mytkalyk Nov 25 '15 at 15:05
0

Your com.facebook.android:facebook-android-sdk:4.1.0 library is messing with parse as both use same bolts-android module internally and having a different version of this module. Try to exclude this module from any of parse or facebook gradle dependency.

compile('com.facebook.android:facebook-android-sdk:4.1.0') {
        exclude group: 'com.parse.bolts',
                module: 'bolts-android'
    }

I was having the same problem and When I run ./gradlew yourModuleName:dependencies by the terminal, I found exactly which two libraries are messing with each other having a different version of the same module internally.

Mahendra Chhimwal
  • 1,810
  • 5
  • 21
  • 33