1

I am trying to build my app but when i try to make it a signed apk it says this:

Error:Execution failed for task ':app:dexRelease'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    C:\Users\rik\AppData\Local\Android\sdk\build-tools\21.1.0\dx.bat --dex --output C:\Users\rik\Desktop\CCApp\app\build\intermediates\dex\release --input-list=C:\Users\rik\Desktop\CCApp\app\build\intermediates\tmp\dex\release\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:302)
        at com.android.dx.command.dexer.Main.run(Main.java:245)
        at com.android.dx.command.dexer.Main.main(Main.java:214)
        at com.android.dx.command.Main.main(Main.java:106)

its really anoying me and i need to build the app very soon, hope someone can help me

EDIT added build.gradle

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    defaultConfig {
        applicationId "it.experium.ccapp"
        minSdkVersion 9
        targetSdkVersion 21
        versionCode 3
        versionName "3.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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

EDIT file tree of the libs folder

parse-1.8.2-javadoc (Folder)
ParseCrashReporting-1.8.2-javadoc (Folder)
bolts-android-1.1.4 (Jar)
bolts-android-1.1.4 (Properties File)
bolts-android-1.1.4-javadoc (Jar)
Parse-1.8.2 (Jar)
Parse-1.8.2 (Properties file)
Rooster (In english Schedule, i have this because i request json's with this file. Jar)
third_party_licenses (TXT)
Rik
  • 511
  • 5
  • 16
  • Show your `build.gradle` file – Ojonugwa Jude Ochalifu Apr 06 '15 at 12:07
  • Ermmm, I hope.You see, the reason for this error is you are having conflicting libraries in your project.That is, you have two of the same library in your build.gradle dependencies. Just take a look at [this](http://stackoverflow.com/questions/21102598/android-studio-unexpected-top-level-exception) SO question, you will find your answer in minutes. – Ojonugwa Jude Ochalifu Apr 06 '15 at 12:17
  • You could also try commenting out the compile commands for the jars one after the other, rebuild the project and see how it goes.Good luck – Ojonugwa Jude Ochalifu Apr 06 '15 at 12:23
  • can you please list out your jar files under libs folder? –  Apr 06 '15 at 12:33

1 Answers1

1

It seems like you are using here multiple jar files for same reference it may take some difference version of it.. So, it's better to remove below lines

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

Because 1st and 3rd line of this code included in single line so, no need to put those extra lines..

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

You are here putting external jar bolts-android-1.1.4 (Jar) as a reference from lib folder so, no need to add this gradle dependency..

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

So, after removing those 3 line sync project you will get your project running without any issue..

Let us know if anything needed...

  • I fixed my error whit the code that you just posted, so thank you also! i fixed the problem – Rik Apr 06 '15 at 13:03