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

4
  • 3
    Look here stackoverflow.com/questions/28640314/… Commented Apr 5, 2015 at 18:03
  • Please share your gradle build. Also if possible try running the same with --info or --debug to get more info Commented Apr 5, 2015 at 18:31
  • Nothing worked for me yet Commented May 23, 2016 at 13:09
  • I found this Git discussion helpful for me: github.com/facebook/rebound/issues/71 Commented Mar 1, 2017 at 6:39

7 Answers 7

47

Add this to your file build. gradle

defaultConfig {
     multiDexEnabled true 
}
Sign up to request clarification or add additional context in comments.

6 Comments

Thank you very much , there seems only one way you can solve this problem . I ask you from where you find it?(Google Translate)
some time ago I experienced the same error. add this code compile 'com.android.support:multidex:1.0.0' for pre-lolipop device
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
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?
@souttab, I think this is a gradle issue but +1 for sharing the solution and comment
|
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'
}

2 Comments

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?
Only setting "multiDexEnabled" true solves the problem, add that dependency is not needed
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.

1 Comment

Cleaning the project and rebuilding solved the problem. For me, the error occurred when I moved the project from one PC to another.
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

Comments

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

Comments

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

Comments

-1

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.