10
votes

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

10
check if your android studio is properly configured and also you have added proper environment variables. - Amrut Bidri
my environment variables are: - AISHWARYA MITTAL
JAVA HOME-C:\Program Files\Java\jdk1.7.0_75 and PATH-C:\Program Files\Java\jdk1.7.0_75\bin\javaw.exe;C:\Program Files\Java\jdk1.7.0_75\bin;C:\Program Files\Java\jdk1.7.0_75\bin\java.exe; - AISHWARYA MITTAL
it must be JAVA_HOME and JDK_HOME pointing to same location C:\Program Files\Java\jdk1.7.0_75; - Amrut Bidri
I am getting 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_75\bin\java.exe'' finished with non-zero exit value 3 - AISHWARYA MITTAL

10 Answers

1
votes

upgraded gradle version

classpath 'com.android.tools.build:gradle:1.1.2'

and updated android studio worked

1
votes

Found 2 resolutions.

I. First one is simple. Open AS error log file (generated in project directory) and if it contains information that there is not enough memory for Java to do it's job - simply close unnecessary applications to free memory and run again.

II. Another one is due to corrupted project files (for some reason): Do project clean up and then import again in Android Studio (AS). That's how to do it in details.

  1. File -> Close project (if it is opened in AS)
  2. Open project directory, search for *.iml files and remove all of them
  3. Remove all generated by AS and build process directories: .gradle .idea build
  4. After that open AS and import project again. Now, wait, wait, wait and you should now be able to run again.

Note: that you'll end up without all project specific AS settings.

That's simply the thing, which I do from time to time when upgrading to latest AS. That is one of the reasons I never commit those AS-related files to VCS (and teammates allways do import in AS after fresh check out from VCS)

0
votes

It is not clear when you got this problem, but I was having a similar problem trying to do a unit test in Android Studio.

My problem was with one of my dependencies (androidannotation). When I removed it, my tests worked well.

0
votes
build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        //multiDexEnabled false

        applicationId "com.example.aishwarya.myapplication"
        minSdkVersion 16
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    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.3'
    //compile files('libs/android-support-v4.jar')
    compile files('libs/gson-2.2.4.jar')
    compile files('libs/okhttp-1.6.0.jar')
    compile files('libs/okhttp-urlconnection-1.6.0.jar')
    compile files('libs/okio-1.0.0.jar')
    compile files('libs/otto-1.3.4.jar')
    compile files('libs/picasso-2.3.1.jar')
    compile files('libs/retrofit-1.5.1.jar')
    compile files('libs/scribe-1.3.5.jar')
    compile files('libs/twitter-text-1.6.1.jar')
    compile 'com.android.support:support-v4:21.0.3'
}
0
votes

I just add these lines and it works. You can try but not sure it will solve your problem.

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_6
    targetCompatibility JavaVersion.VERSION_1_6
}
0
votes

I have the same problem. It heppends when your "C" drive has no free place. Just clear "C" drive and restart Android Studio. Sorry for my English.

0
votes

I fixed this issue by upgrading the Gradle Build version in Android Studio. You can do this using:

dependencies {
    classpath 'com.android.tools.build:gradle:1.3.0'
}
0
votes

After trying every single one of the solutions, the only thing that helped me was removing the "multiDexEnabled true".

0
votes

Let me talk about my story. I had Ubuntu 14.04 installed in Virtual Box, and i tried to run gradle task ./gradlew assembleDebug to compile my project, which uses git as version control system. Unfortunately, each time unexpectedly stopped for no specific reason, except the following error log:

*…

:dexDebug FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':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 1*

Googling for days, tried every possible solutions, I still failed to build. Then I tried to comment out multiDexEnabled in the build.gradle file, this time gradle gave a bit more useful tip: "build stopped as too many translation errors", something like this. Then I ran git status and found many error logs, as shown below:

error logs

furthermore, the number of the error log files are almost the same as the number of build failure times. That's it! each build failure generated an error log file!

check one of the error log, hs_err_pid3143.log, and ensure that the build failures were caused by insufficient memories.

insufficient memory.

So the solution is relatively easy:

  1. Shut down Ubuntu OS in VirtualBox.
  2. Enlarge base memory from 4G to 6G, and Restart Ubuntu OS in VirtualBox.

Note: generally, dexDebug task will eat most of the memory. in my case, the base memory in VirtualBox was 4GB before changing to 6GB, and javaMaxHeapSize had been set to "4g", it still failed.

dexOptions {
    javaMaxHeapSize "4g"
}

Sometime building is not so easy, hopefully my post helps.

-1
votes

The problem is with this line

('com.android.support:support-v4:22.0.0')

from dependencies as :

dependencies {
compile files('libs/cordova-2.7.0.jar')
compile files('libs/google-play-services.jar')
compile files('libs/java_websocket.jar')
compile 'com.android.support:support-v4:22.0.0'
}

in project.gradle file.. Remove it..