[java] Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException

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.8.0_40\bin\java.exe'' finished with non-zero exit value 2

I searched all the similar questions and solutions, but they do not help. I hope experts like you come up.

The project code has been uploaded into bitbucket: https://[email protected]/tainule/numad-huizhang.git

I have two modules, app and endpoint. Below is from Module:app:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "edu.neu.madcourse.huizhang1"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 3
        versionName "2.1"
//        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
    }
}

dependencies {


    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile "com.android.support:appcompat-v7:21.0.+"
    compile 'com.google.android.gms:play-services:+'
    compile 'com.google.guava:guava:18.0'
    compile 'com.google.code.gson:gson:1.7.2'
    compile 'org.apache.httpcomponents:httpmime:4.4-beta1'
    compile 'org.apache.httpcomponents:httpclient:4.4-beta1'
    compile 'org.apache.httpcomponents:httpcore:4.4-beta1'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
    compile project(path: ':endpoint', configuration: 'android-endpoints')
    compile files('src/main/res/libs/KeyValueAPI.jar')

}

Below is from Module endpoint:

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath 'com.google.appengine:gradle-appengine-plugin:1.9.17'
    }
}

repositories {
    mavenCentral();
}

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'

sourceCompatibility = 1.7
targetCompatibility = 1.7

dependencies {
    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.8'
    compile 'com.google.appengine:appengine-endpoints:1.9.8'
    compile 'com.google.appengine:appengine-endpoints-deps:1.9.8'
    compile 'javax.servlet:servlet-api:2.5'
    compile 'com.googlecode.objectify:objectify:4.0b3'
    compile 'com.ganyo:gcm-server:1.0.2'
//        compile 'com.github.fengdai:alertdialogpro-theme-material:0.1.0'

}

appengine {
    downloadSdk = true
    appcfg {
        oauth2 = true
    }
    endpoints {
        getClientLibsOnBuild = true
        getDiscoveryDocsOnBuild = true
    }
}

This question is related to java android gradle

The answer is


Try to clean and rebuild the project. I had the absolutely same question, this solved it.


I encountered the same exact error message. I am not quite sure if my solution will solve also your issue.

In Project Structure (app) I changed the Compile SDK Version from API 22 to API 21 and changed Build Tools Version from 22.0.0 to 21.1.2.

When I downloaded the latest API 22 Adroid 5.1, every project I create is using this API and causes me the problem. Maybe, Android Team is looking for a fix for this one.


I had the same problem error that is shown, i solve it by adding

defaultConfig {        
    // Enabling multidex support.
    multiDexEnabled true
}

I had this problem cause i exceeded the 65K methods dex limit imposed by Android i used so many libraries


This could also be the case when you have too many object references. Take a look at the results from the build, esp in the task :dex:multiDebug:

trouble writing output: Too many method references: 67114; max is 65536.


I solved the same issue by removing:

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

and adding for each jar file:

compile files('libs/yourjarfile.jar')

I recently migrated one of our corporate projects from Eclipse to Android Studio.

We too got the below error during the migration:

Error:Execution failed for task ':appName:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: 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

To resolve it, we had to do a few things:

  1. Remove/Update duplicate jars/files from libs

compile 'com.android.support:support-v4:23' compile 'com.google.android.gms:play-services:9.0.0'

to compile 'com.google.android.gms:play-services:9.0.0'

  1. Set multiDexEnabled to True

defaultConfig { multiDexEnabled true }

  1. Increase the heap size:

dexOptions { incremental true javaMaxHeapSize "4g" }


three condition may cause this issue.

  1. differ module have differ jar
  2. in libs had contain jar,but in src alse add relevant source
  3. gradle repeat contain,eg:

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

    compile files(‘libs/xxx.jar’)

if you can read chinese ,read hereError:Execution failed for task ':app:dexDebug'.> com.android.ide.common.process.ProcessException: o


It seems you have a jar file or a lib appearing multiple times.

So, remove the .jar file from the lib folder then:

Build > Rebuild


For me I had multiple versions of the same library included in /app/libs. I was using Parse and I had both ParseFacebookUtilsV3-1.9.0.jar and ParseFacebookUtilsV4-1.9.0.jar.

Deleting the V3 jar solves the problem.


I faced same issue when converting an eclipse project to Android studio.In my case i had the design lirary jar file in eclipse project and I have added dependency of the same in gradle caused the error.I solved it by deleting jar from libs.


Try to put this line of code in your main projects gradle script:

configurations { all*.exclude group: 'com.android.support', module: 'support-v4' }

I have two libraries linked to my project and they where using 'com.android.support:support-v4:22.0.0'.

Hope it helps someone.


I've got this problem after including same classes twice


I am adding it so that someone in a similar situation might find it helpful.

So, even after multiDexEnabled = true I was getting the same error. I had no duplicate libraries. None of the above solutions worked. Upon reading the error log, I found OutOfMemError issue to be the primary reason and thought of changing the heap size somehow. Hence, this -

dexOptions {
        preDexLibraries = false
        javaMaxHeapSize "4g"
    }

Where "4g" means HeapSize of 4 GB. And it worked! I hope it does for you too.


I changed :

compile 'com.google.android.gms:play-services:9.0.0'

compile 'com.google.android.gms:play-services-auth:9.0.0'

to :

compile 'com.google.android.gms:play-services-maps:9.0.0'

compile 'com.google.android.gms:play-services-auth:9.0.0'


I have the same issue, and solved by change the '+' to a exact number, like compile "com.android.support:appcompat-v7:21.0.+" to compile "com.android.support:appcompat-v7:21.0.0".

This works for me. :)


Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to gradle

Gradle - Move a folder from ABC to XYZ A failure occurred while executing com.android.build.gradle.internal.tasks Gradle: Could not determine java version from '11.0.2' Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 Failed to resolve: com.android.support:appcompat-v7:28.0 Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0)