0

For some reason my project stopped working. When I try to run it I get the following error:

Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    C:\Users\LENOVO\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --output C:\Users\LENOVO\Projects\Stock.comLiveV2\b18-v12-1903\app\build\intermediates\dex\debug --input-list=C:\Users\LENOVO\Projects\appy\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
    2
Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Lbolts/AggregateException;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
        at com.android.dx.command.dexer.Main.run(Main.java:246)
        at com.android.dx.command.dexer.Main.main(Main.java:215)
        at com.android.dx.command.Main.main(Main.java:106)

The project was fine yesterday and I didn't change anything sense. my gradle files:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.stock.app"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 4
        versionName "1.0.4"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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


    compile 'com.squareup.picasso:picasso:2.5.0'
    compile 'com.facebook.android:facebook-android-sdk:3.21.1'
    compile 'com.google.android.gms:play-services:6.1.+'

    compile files('libs/gson-1.7.jar')


    compile ('oauth.signpost:signpost-commonshttp4:1.2.1.2') {
        exclude module: 'commons-logging'
        exclude module: 'httpcore'
        exclude module: 'httpclient'
    }
    compile ('oauth.signpost:signpost-core:1.2.1.2') {
        exclude module: 'commons-codec'
    }


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


    compile 'com.mcxiaoke.volley:library:1.0.+'
}

what can I do? After searching for a solution a found one that says to replace this:

classpath 'com.android.tools.build:gradle:1.0.1'

with this:

classpath 'com.android.tools.build:gradle:1.1.2'

But it did not work.

Update: I tried removing parse bolts but the same error eccours. My current gradle:

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


    compile 'com.squareup.picasso:picasso:2.5.0'
    compile 'com.facebook.android:facebook-android-sdk:3.21.1'
    compile 'com.google.android.gms:play-services:6.1.+'

    compile files('libs/gson-1.7.jar')


    compile ('oauth.signpost:signpost-commonshttp4:1.2.1.2') {
        exclude module: 'commons-logging'
        exclude module: 'httpcore'
        exclude module: 'httpclient'
    }
    compile ('oauth.signpost:signpost-core:1.2.1.2') {
        exclude module: 'commons-codec'
    }


    compile fileTree(dir: 'libs', include: 'Parse-*.jar')


    compile 'com.mcxiaoke.volley:library:1.0.+'
}

Edit: as it turns out, the problem was that I had 3 bolts: one from Facebook, one from Parse.com and one from app-compact. I had to remove 2 of them.

What I still don't understand is how the project worked so far - as for I am using all of those libraries from day 1.

EladB
  • 326
  • 5
  • 15

2 Answers2

0

The problem occurs because you're trying to a package the same artefact twice. As you can see here from the "facebook-android-sdk" POM file, this library already packages the "bolts-android". So simply remove this dependency from the build file and it should work:

compile 'com.parse.bolts:bolts-android:1.+'
Egor
  • 39,695
  • 10
  • 113
  • 130
0

The Facebook SDK and the appcompact library come with the lbolts-android library that could cause a version mismatch and thus the DexException.

Check this question.

Look at what private libraries are included in your project, especially if there are multiple instances of lbolts.

Community
  • 1
  • 1
AKroell
  • 622
  • 4
  • 18