Error building Gradle Android Studio 1.5.1 (Error: Execution failed for task ': app: dexDebug'.)

4

I have the following error when trying to build my application,

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

I guess it has to do with the dependencies that I add to the project but I can not solve it, This is my Build.Gradle (app): apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"


    repositories {
        mavenCentral()
    }


    defaultConfig {
        applicationId "com.jmhe.corebo"
        minSdkVersion 15
        targetSdkVersion 23
        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 files('libs/gson-2.2.2.jar')
        compile files('libs/guava-17.0.jar')
        compile files('libs/mobileservices-2.0.3-javadoc.jar')
        compile files('libs/mobileservices-2.0.3-sources.jar')
        compile files('libs/mobileservices-2.0.3.jar')
        // compile 'com.facebook.android:facebook-android-sdk:4.1.0'
        compile project(':facebook')
        compile files('libs/json-simple-1.1.1.jar')
        compile 'com.android.support:appcompat-v7:23.1.1'
        compile 'com.android.support:design:23.1.1'
        compile 'com.squareup.picasso:picasso:2.5.2'
        compile 'com.google.android.gms:play-services:8.3.0'
    }

Before I built, the last thing I added to the project was the default template MapsActivity, with the rest everything was the same.

    
asked by Jomazao 08.01.2016 в 00:18
source

2 answers

1

It seems that your dependencies are being compiled 2 times:

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

That line compiles all the jar and then below you compile each one.

Check out this reference in English .

    
answered by 08.01.2016 в 00:36
0

Try adding multiDexEnabled true to build.gradle in defaultConfig.

 defaultConfig {
    //..
    multiDexEnabled true
}

Note: in some cases this not only does not solve it, but it generates more errors if this is the case undo the changes .

P.D: if the above solves the error, you may want to use only the part of the google services that interests you here, an example for analytics. Instead of using such compile 'com.google.android.gms:play-services:x.x.x' when you could use compile 'com.google.android.gms:play-services-analytics:x.x.x' for example if you only need the analytics , with this decrease the size of your APK and may not have to use the multiDexEnabled .

You can look at my answer here for similar cases: failed to want to raise my application in Android Studio 1.5.1 Execution (Error: Execution failed for task ': app: transformClassesWithDexForDebug'.)

    
answered by 11.01.2016 в 03:44