Sergiohernandez
Sergiohernandez

Reputation: 103

Android studio does not let me compile project

I have googled to find a solution, but I have tried all the ways and any of them works. First my project works with any problem, later I added some changes and this happened. When I delete all the changes, the problem has not dissapeared. When I try to complie the project, gradle console shows:

    FAILURE: Build failed with an exception.

    What went wrong:

    Execution failed for task ':app:dexDebug'.
    > com.android.ide.common.internal.LoggedErrorException: Failed to run command:
        /home/user/Android/Sdk/build-tools/22.0.0/dx --dex --no-optimize --output /home/projectpath/app/build/intermediates/dex/debug --input-list=/home/projectpath/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)

This is my build.gradle file:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.0"

    defaultConfig {
        applicationId "application.com.name"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.android.support:palette-v7:+'
    compile 'com.android.support:recyclerview-v7:+'
    compile 'com.android.support:cardview-v7:22.0.+'
    compile 'com.jakewharton:butterknife:5.1.2'
    compile 'com.jakewharton.timber:timber:2.5.0'

    compile 'fr.tvbarthel.lib.blurdialogfragment:lib:1.1.0@aar'

    compile 'com.github.chenupt.android:multiplemodel:1.1.0@aar'
    compile 'de.greenrobot:eventbus:2.4.0'
    compile 'com.google.guava:guava:18.0'
    compile 'com.jpardogo.materialtabstrip:library:1.0.8'
    compile 'com.getbase:floatingactionbutton:1.7.0'
    compile 'com.squareup.picasso:picasso:2.5.0'

    compile 'com.facebook.android:facebook-android-sdk:3.21.1'
}



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

Upvotes: 0

Views: 798

Answers (1)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363469

This kind of issue UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: happens when you are using the same library with a different version.

The problem is here:

You are using

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

Currently the version is 1.2

The facebook (3.21.1) library is using the 1.1.2 version

Also you are using

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

It means the release 22. The facebook library uses the 20-21.

Upvotes: 0

Related Questions