45

I am trying to run the app in debug mode but I get the following error:

Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_11\bin\java.exe'' finished with non-zero exit value 2

Below is my build.gradle file:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'idea'


repositories {
    maven { url 'https://maven.fabric.io/public' }
}


android {
    compileSdkVersion 21
    buildToolsVersion '21.1.1'
    defaultConfig {
        applicationId 'com.rayat.pricewiz'
        minSdkVersion 17
        targetSdkVersion 21
        versionCode 1
        versionName '1.0'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            multiDexEnabled true
        }
    }
    productFlavors {
    }
}

android {
    packagingOptions {
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    dexOptions {
        jumboMode = true
        javaMaxHeapSize "4g"
    }
}

dependencies {
    compile 'com.android.support:multidex:1.0.0'
    compile files('libs/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar')
    compile files('libs/universal-image-loader-1.9.2.jar')
    // You must install or update the Google Repository through the SDK manager to use this dependency.
    // You must install or update the Google Repository through the SDK manager to use this dependency.
    compile 'com.google.android.gms:play-services:6.1.71'
    compile 'com.android.support:recyclerview-v7:+'
    compile files('libs/CWAC-SackOfViewsAdapter.jar')
    compile 'com.octo.android.robospice:robospice:1.4.14'
    compile 'com.octo.android.robospice:robospice-spring-android:1.4.14'
    compile 'com.facebook.android:facebook-android-sdk:3.21.1'
    compile('com.twitter.sdk.android:twitter:1.1.1@aar') {
        transitive = true;
    }
    compile files('libs/javax.mail.jar')
    compile files('libs/jackson-databind-2.5.0.jar')
    compile files('libs/jackson-all-1.9.11.jar')
    compile files('libs/jackson-mini-1.9.11.jar')
    compile files('libs/scanditsdk-barcodepicker-android-4.2.1.jar')
    compile files('libs/nineoldandroids-2.4.0.jar')
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
    compile 'com.squareup.okhttp:okhttp:2.0.0'
}

Can anyone please help as this error is driving me crazy. My code is hitting 65k limit so I added multiDexEnabled option.

EDIT My project architecture enter image description here enter image description here enter image description here

Thanks

Noorul
  • 919
  • 1
  • 11
  • 20

3 Answers3

99

That is because you enabled multiDex for release builds only, not for debug builds.

Try this:

defaultConfig {
    multiDexEnabled true
}
clemp6r
  • 3,406
  • 1
  • 23
  • 31
  • 3
    Any clue why I'd be seeing this? createDebugMainDexClassList'. A problem occurred starting process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_76.jdk/Contents/Home/bin/java'' `error=0, spawn failed` – amadib Mar 02 '15 at 23:17
  • Trying for two days! This line solved it! Can you please enlighten us about this config? – nizam.sp Aug 27 '15 at 19:26
  • 1
    i get this error java.util.zip.ZipException: duplicate entry: com/squareup/okhttp/Address.class any idea.. – Mr.G Nov 12 '15 at 07:44
  • http://stackoverflow.com/questions/39071979/android-studio-errorexecution-failed-for-task-apptransformclasseswithdexforde – Amit Desale Aug 24 '16 at 08:23
  • 2
    i got this error Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_66\bin\java.exe'' finished with non-zero exit value 1 – Amit Desale Aug 24 '16 at 08:23
4

Try this

dexOptions {
    incremental true
    javaMaxHeapSize "4g"
}
Tunaki
  • 116,530
  • 39
  • 281
  • 370
Vikrant
  • 602
  • 5
  • 5
3

Just see :: Configuring Your App for Multidex with Gradle on Android developer official docs

serabile
  • 329
  • 3
  • 11