1
votes

i want to start my application "app" , i got a error while building gradle :

Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.internal.LoggedErrorException: Failed to run command: C:\Users\jaafar\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Users\jaafar\AndroidStudioProjects\helooandroidstudio\app\build\intermediates\dex\debug --input-list=C:\Users\jaafar\AndroidStudioProjects\helooandroidstudio\app\build\intermediates\tmp\dex\debug\inputList.txt Error Code: 2 Output: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Lcom/facebook/AccessToken$1; 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

apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.heloo"
    minSdkVersion 9
    targetSdkVersion 21
    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:21.0.3'
compile 'com.facebook.android:facebook-android-sdk:+'
compile 'com.vk:androidsdk:+'
compile 'org.altbeacon:android-beacon-library:2+@aar'
compile 'com.mcxiaoke.volley:library:1.+'
compile project(':reco-sdk-android_0.1.55')
compile project(':reco-sdk-android_0.1.5_JavaDoc')
compile project(':facebook')
 }

this is my updated build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.heloo"
    minSdkVersion 9
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}
   dexOptions { 
   preDexLibraries = false 
  }
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.facebook.android:facebook-android-sdk:+'
compile 'com.vk:androidsdk:+'
compile 'org.altbeacon:android-beacon-library:2+@aar'
compile 'com.mcxiaoke.volley:library:1.+'
compile project(':reco-sdk-android_0.1.55')
compile project(':reco-sdk-android_0.1.5_JavaDoc')
compile project(':facebook')

}

2
I've had this very same issue a while ago, it's because you're using a few libraries (like app compat and facebook's) which each one contains app-compat's dex files... I fixed it adding this code to the build.gradle file dexOptions { preDexLibraries = false }Jonatan Collard Bovy
i didn't found dexOptions fileIsmaili Alaoui smail
Rebuild Project or Clean Project, have a try.SilentKnight

2 Answers

1
votes

I meant to post it as an answer instead of a comment

You should add this code to your build.gradle

dexOptions { 

preDexLibraries = false }

1
votes

it's fixed , my problem was not in the build.gradle , my app contained 2 conflict module dependency in the dependencies ( 2 facebook module ) , i kept the one that i use and removed the other and it's working ! thanks guys any way