25

Could anyone help me out with the following error. When i clean the project, it doesn't show any error but every time i try to run i get this message.

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

The application was running with no errors but as my system crashed and restarted android studio i had few updates for Android API 22. After the update the application keep giving me this error message. I downloaded JDK 8 and tried to run but didn't work. Later i downgraded to JDK 7 after this stack post but still has not fixed it. Is it possible to use Java 8 for Android development?

I have looked through numerous similar question but none works for me. Some similar issues found on stack were

why java.exe exit with value 1 in android studio

Error:Execution failed for task ':app:dexDebug'. > comcommand finished with non-zero exit value 2

Java finished with non-zero exit value 2 - Android Gradle

java.exe finished with non-zero exit value 2

Process 'command' C: \ Program Files \ Java \ jdk1.8.0_31 \ bin \ java.exe '' finished with a non -zero exit value 2

I have looked through dependencies in gradle built to see if there were any conflict but found none.

I even tried to copy the code into a new project and run it but still no success. Anyone who has faced the same issue and solved it please help me out.

Satish_Mhetre
  • 192
  • 1
  • 2
  • 17
Prajun Adhikary
  • 637
  • 1
  • 6
  • 8

13 Answers13

35

After days of trying out finally could fix the issue. The problem with one of my .jar files. I had to remove each jar and check one by one until i found it. I removed the .jar file and cleaned my project and ran successfully. If any one should face similar issue check your jar file one by one.

Prajun Adhikary
  • 637
  • 1
  • 6
  • 8
30

I had the same error

app:dexDebug ExecException finished with non-zero exit value 2

i solve it by adding this line of code

defaultConfig {
        multiDexEnabled true
}

The reason is that i was using too many libraries

Hope this post will help anyone

Netero
  • 3,761
  • 2
  • 29
  • 29
  • 1
    this code go in your gradle build file, for more information see : http://developer.android.com/tools/building/multidex.html – Netero Dec 25 '15 at 08:52
8

I had the same problem when I compiled google play services to my dependencies.

My mistake was I was compiling the enitre package like this

compile 'com.google.android.gms:play-services:8.3.0'

Instead when I tried the selective compile, it worked.In my case I was using for google sign in,so it had just had to be

compile 'com.google.android.gms:play-services-auth:8.3.0'.

More details are in the documentaion. https://developers.google.com/android/guides/setup#split

Hope this will be of a little help to someone someday :)

4

I know it's late. But that's what actually worked for me.

1. Build > Clean Project
2. Close gradle daemon processes (ps -e| grep gradle  //this will list gradle processes)
3. File > Invalidate caches & Restart

I hope this will work for everyone.

Sandeep Rana
  • 3,251
  • 2
  • 24
  • 38
3

For me the solution was to remove an unnecessary/duplicate dependency entries. This is a similar solution others offered here that makes sense, but not exactly the same solution as those offered by others.

Since I was already including *.jar files in the list of files to be compiled, there was no need for additional entries in the dependencies list.



Before:

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

    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile fileTree(dir: 'libs', include: 'Parse-*.jar')
}

After:

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

compile 'com.android.support:appcompat-v7:22.2.0'

}

joshgoldeneagle
  • 4,616
  • 2
  • 23
  • 30
3

For future readers. If you're using your own AARs and upgraded one that has a shared dependency, you can also just try cleaning the project. In Android Studio "Build" -> "Clean Project".

This solved the issue for me, so I'd recommend giving it a quick try before you start digging for dependencies.

Matt Edwards
  • 133
  • 1
  • 6
  • This happens more if the AARs are part of source control, and pushed by other developers. (switch to a local maven server) – Matt Edwards Sep 24 '15 at 21:04
2

Remove compile 'com.parse:parse-android:1.+'

add this linecompile fileTree(dir: 'libs', include: ['Parse-*.jar'])

Finally, it will look like this

dependencies {
compile fileTree(dir: 'libs', include: ['Parse-*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
compile 'com.android.support:design:22.2.0'
compile 'com.parse.bolts:bolts-android:1.+'
}
Keyul
  • 729
  • 1
  • 8
  • 20
1

I had the same problem, just i did Biuld--> Rebiuld project and it works again ;)

0

I was using the robolectric dependency in my android project. I removed all robolectric dependencies in gradle and deleted all my robolectric tests, then I built the app and finally I could run the android project. Hope this can work for us.

0

I faced the same problem when trying to add the SignalR Java client library to my project's dependencies. I first changed the target JDK of my app from 1.8.0_XX to 1.7.0_XX, but it didn't work. Then I changed the SignalR project to target 1.7.0_XX as well, rebuilt and added it to my project's libs folder instead of the first build (which was in 1.8.0_XX), and that miraculously worked.

Neria Nachum
  • 1,519
  • 1
  • 20
  • 37
0

For me, the problem was that I was using different versions of "Google Play services sub API's"

Before: Click to see the image

After: Click to see the image

shahrukhamd
  • 259
  • 6
  • 6
0

Check if there are 2 classes with same name. Each class name should be unique.

Steve Ham
  • 3,067
  • 1
  • 29
  • 36
0

maybe for this issue you got means you added same liberay file in more than one time

S HemaNandhini
  • 333
  • 3
  • 5