19

I am building my android project when i got this error after import docx4j library in my project. What should i do to get rid of this exception.

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

Wahib
  • 249
  • 1
  • 2
  • 7

7 Answers7

47

Add this to your file build. gradle

defaultConfig {
     multiDexEnabled true 
}
commit
  • 4,607
  • 14
  • 38
  • 68
souttab
  • 686
  • 6
  • 11
  • 2
    Thank you very much , there seems only one way you can solve this problem . I ask you from where you find it?(Google Translate) – oldfeel Jul 01 '15 at 07:58
  • some time ago I experienced the same error. add this code compile 'com.android.support:multidex:1.0.0' for pre-lolipop device – souttab Jul 07 '15 at 06:28
  • solves the problem but each compilation takes equal time to make a clean build.. :'( ..It does not work for me, so I returned it to 7.21 – Hpsaturn Jul 28 '15 at 20:48
  • Do i need to give it in the every module's gradle file of my applications. for example I am having 7 modules along with the main app module of my app? – Pravinsingh Waghela Nov 24 '15 at 06:48
  • @souttab, I think this is a gradle issue but +1 for sharing the solution and comment – Aravind.HU Feb 17 '16 at 08:36
  • Error:(23, 0) Gradle DSL method not found: 'defaultConfig()' Possible causes: – Siddharth Apr 28 '16 at 08:29
9

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'
}
serabile
  • 329
  • 3
  • 11
6

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.

SuperBiasedMan
  • 8,997
  • 9
  • 43
  • 66
TomaTo
  • 63
  • 7
  • 1
    Cleaning the project and rebuilding solved the problem. For me, the error occurred when I moved the project from one PC to another. – lenooh Oct 21 '15 at 20:20
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

Community
  • 1
  • 1
San
  • 2,143
  • 20
  • 38
2

I had got the same error. But I resolved the issue by adding the following missing line from build.gradle in dependencies. compile 'com.parse.bolts:bolts-android:1.+'

After adding this line, my dependencies body was like this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile fileTree(dir: 'libs', include: "commons-io-2.4.jar")  }

You can match with yours too and see if it can help you too

2

the same as my error

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 2enter code here

it is because there is a duplication of its dependency lib, in my case like this

compile files('libs/httpcore-4.3.3.jar') compile files('libs/httpmime-4.3.6.jar') compile fileTree(include: ['*.jar'], dir: 'libs')

then I fixed it to be like this compile fileTree(include: ['*.jar'], dir: 'libs') remove other setting import lib

I hope this helps

souttab
  • 686
  • 6
  • 11
-1

This Problem can easily be resolved by Removing multiple jar in your project libs folder.

mehmoodnisar125
  • 1,253
  • 13
  • 13