Search code examples
androidbuildinterface-builderandroid-gradle-pluginbuild-process

Android: Execution failed for task ':dexDebug'


I am currently facing a problem when I change the targetSDK version from 21 to 23.

After changing and the build the gradle, When I try to run the application am getting an error

Error:Execution failed for task ':dexDebug'.
 > com.android.ide.common.process.ProcessException:   org.gradle.process.internal.ExecException:
 Process 'command 'C:\Program Files\Java\jdk1.8.0_66\bin\java.exe'' finished with non-zero exit value 

In my lib folder I have a library called org.apache.http.legacy

This library i added when change the sdk version from 21 to 23 , because in 23 it is depricated.

  • Sync: OK
  • Make Project: OK
  • Clean: OK
  • Run: Error

My gradle file is

buildscript {
repositories {
    mavenCentral()
}
dependencies {

    classpath 'com.android.tools.build:gradle:1.3.0'
}
}
apply plugin: 'android'

 dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:23.1.1'
compile('com.android.support:support-v4:21.0.3') {
    exclude module: 'support-v4'
}

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
}
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.google.android.gms:play-services:7.8.0'
}

 android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'

defaultConfig {
    minSdkVersion 11
    targetSdkVersion 23

}

In my lib folder i have

  • armeabi
  • armeabi-v7a
  • x86
  • android-support-v4.jar
  • gcm.jar
  • json.jar
  • org.apache.http.legacy.jar
  • tint.jar
  • webproc.jar

Can any please help me to resolve the error Error:Execution failed for task ':dexDebug'.finished with non-zero exit value 2

I heard that it may because of jar issue. several times i delete and paste new jar from Local\Android\sdk\platforms\android-23\optional. But still facing the same issue

Can anyone please help me


Solution

  • Please remove V4 support library because you are already using appcompat-v7.