Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException

Solution 1:

Add this to your file build. gradle

defaultConfig {
     multiDexEnabled true 
}

Solution 2:

The Android plugin for Gradle available in Android SDK Build Tools 21.1 and higher supports multidex, so you have to add multiDexEnabled true to your gradle file like below :

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    defaultConfig {
        ...
        minSdkVersion 14
        targetSdkVersion 21
        ...

        // Enabling multidex support.
        multiDexEnabled true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.0'
}

Solution 3:

I might need more information but according to the error on your question:

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-openjdk-amd64/bin/java'' finished with non-zero exit value 2

The IntelliJ compilation way might cause the error you post (at least in my case, it does). I recently came from Eclipse, where a 'Clean Project' is made after every run. In IntelliJ, the project needs a clean build to be run. I've avoided cleaning every time, disabling incremental flag inside dexOptions of the build.gradle.

Solution 4:

I ran into the same problem and I did add the multiDexEnabled true in build file but all in vain. But doing the following along with adding multiDexEnabled true in defaultConfig solved my problem.

Add the MultiDexApplication in your manifest like :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.multidex.myapplication">
    <application
        ...
        android:name="android.support.multidex.MultiDexApplication">
        ...
    </application>
</manifest>

And dont forget to add

defaultConfig {
     multiDexEnabled true 
}

The did the trick for me. Ref : Android Studio fails to debug with error org.gradle.process.internal.ExecException