5

When I try to Run my app, I am getting this 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_79\bin\java.exe'' finished with non-zero exit value 2

UPDATED:- Here is my Build.gradle(Module:app) file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "navigationdrawer.tutecentral.com.navigationdrawer"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.1'
}

What does that means?

Konrad Krakowiak
  • 12,285
  • 11
  • 58
  • 45
adafrwefsefr
  • 393
  • 1
  • 3
  • 15
  • Share your build.gradle (module app) file here. – Mohammad Arman May 23 '15 at 07:37
  • Nothing wrong in your build.gradle. You can do one simple thing. Close this project and Create a new hello world project and try to run it. If that project also says the same thing then you have to uninstall all the JDK from your pc and install the latest version. And if the hello world project runs without any error then we have find the cause again. – Mohammad Arman May 23 '15 at 08:02
  • I have Checked that before,all other projects are running fine other than in this project – adafrwefsefr May 23 '15 at 08:04
  • 2
    possible duplicate of [android project: process finished with non-zero exit value 2](http://stackoverflow.com/questions/30320057/android-project-process-finished-with-non-zero-exit-value-2) – Mogsdad Aug 12 '15 at 12:08

7 Answers7

6

I got this error when I used the beta version of gradle to test Vector Asset. This error perssisted even after I switched back to stable Gradle version 1.3.0.
The error was fixed after I used Build > Clean project

vovahost
  • 34,185
  • 17
  • 113
  • 116
6

Just add below line in your app Gradle dependencies

compile 'com.android.support:multidex:1.0.0'

and then below line in defaultConfig

multiDexEnabled true
SeniorJD
  • 6,946
  • 4
  • 36
  • 53
Bajirao Shinde
  • 1,356
  • 1
  • 18
  • 26
5

This happened for me when I was refactoring some class files to a library project and I had a duplicate name of a class file. So, double check that you do not have any duplicate names. This also appears to be a duplicate of the question here: android project: process finished with non-zero exit value 2

cdwheatley
  • 179
  • 3
  • 3
    can you be more specific, even I am getting the same error I could not figure it out where the duplicate class files are. – Navakanth Jul 10 '15 at 06:14
2

Encountered same problem today. I fixed this problem by closing other applications to release more memory to finish build process.

When getting this error:

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 2

Use process explorer to find out the command line parameter of java.exe, then run complete command in CMD window to see what the error message is. Mine contains "HeapDumpOnOutOfMemoryError", So I close other applications to release more memory, then problem fixed.

johnlp
  • 21
  • 1
1

Try

Build > Clean project

If it not working try to remove

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

then add lib separeately e.g.

compile files('libs/jncryptor-1.1.0.jar')
UmAnusorn
  • 10,420
  • 10
  • 72
  • 100
0

Just do this Build > Clean project

It works

rajlaxmi_jagdale
  • 1,370
  • 15
  • 16
0

Edit gradle.properties file. change this line:

org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

to:

org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Mkurbanov
  • 197
  • 3
  • 13