Error:Execution failed for task ':app:dexDebug'. finished with non-zero exit value 2 with Facebook Fresco
Asked Answered
E

1

5

I've read every single thread regarding this issue here and I can't find any answer to my problem.

After adding the Fresco lib I'm getting this error when building my app. The problematic line is: compile 'com.facebook.fresco:fresco:0.5.3+' The 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_71\bin\java.exe'' finished with non-zero exit value 2

If I take the fresco compile line out, it works.

My gradle looks like this :

buildscript {
    repositories {
        mavenCentral()
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        //classpath 'org.robolectric:robolectric-gradle-plugin:1.1.0'
    }
}

allprojects {
    repositories {
        mavenCentral()
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
    }
}

apply plugin: 'com.android.application'
//apply plugin: 'org.robolectric'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    defaultConfig {
        applicationId "com.maddogs.mymoney"
        minSdkVersion 11
        targetSdkVersion 22
        //testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
    }
    sourceSets {
        androidTest {
            setRoot('src/test') //note that this is androidTest instead of instrumentTest
        }
    }

    productFlavors {
    }

    lintOptions {
        abortOnError false
    }
}

dependencies {

    compile 'com.facebook.fresco:fresco:0.5.3+'
    compile 'com.facebook.android:facebook-android-sdk:4.3.0'

    compile 'com.facebook.stetho:stetho:1.1.1'
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'de.greenrobot:eventbus:2.4.0'
    compile 'com.google.android.gms:play-services:7.5.0'
    compile 'com.jakewharton:butterknife:6.1.0'
    compile 'com.android.support:support-v4:22.2.0'
    compile 'com.android.support:recyclerview-v7:22.2.0'
    compile 'com.android.support:cardview-v7:22.2.0'
    compile 'com.android.support:design:22.2.0'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
    compile 'com.bignerdranch.android:recyclerview-multiselect:+'
    compile files('libs/Parse-1.9.2.jar')
    compile files('libs/ParseCrashReporting-1.9.2.jar')
    compile files('libs/ParseFacebookUtilsV4-1.9.2.jar')
}

Thanks in advance !

Ermaermanno answered 30/6, 2015 at 2:52 Comment(0)
S
13

Sometimes app:dexDebug error is shown when a library is being included more than once in your project. When the error is not related with any dependencies in your app, then it is probably the 65k method limit problem. The Dalvik Executable specification limits the total number of methods, you can read more about it here.

Modify your app Gradle build file configuration to include the support library and enable multidex output, as shown in the following Gradle build file snippet:

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    defaultConfig {
        ...
        minSdkVersion 14
        targetSdkVersion 21
        ...

        // Enabling multidex support.
        multiDexEnabled true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.0'
}
Snippet answered 30/6, 2015 at 3:40 Comment(3)
I removed compile 'com.android.support:support-v4:22.2.0' still no luck. The problem started after I added Fresco to my gradle, if I delete it's line, it compiles without a problem.Ermaermanno
Perhaps is the method limit problem? Try to enable multidex support, use "multiDexEnabled true" in your defaultConfig.Snippet
It worked Heloisa, thank you so much ! If I may, i'd suggest you to post the multiDex solution as an answer (or edit your above), so we can help other people in the future who face the same problem ! Thank you again !Ermaermanno

© 2022 - 2024 — McMap. All rights reserved.