18

I do know Multiple dex problems have been reported a lot of times before, but none of the solutions seems to work in my case.

Console:

    Unable to execute dex: Multiple dex files define Lbolts/AggregateException;
    Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lbolts/AggregateException;

One of the popular solutions is unmarking the 'Android private libraries' container from buildpath. I cannot do that because there are a few more libraries in that container that i need.

Another solution is unmarking any duplicate library explicitly added in .jar form. I have no such libraries.

The duplicate library in my case is: android-support-v7-appcompat.jar I have it (directly referenced from the sdk folder) in these two containers:

1.) Android Private Libraries

2.) Android Dependencies

The problem is that i just cannot untick any of these two containers completely, because both of them contain other necessary libraries. But i also am unable to remove just this duplicate .jar file from either containers.

EDIT: N.B. When i add the android-support-v7-appcompat library_project to my project, it enters into both containers. There must be some way so that goes into only one.

Can any one help me how i can do it?

screenshot

screenshot2 (unable to delete)

Abdul Wasae
  • 3,614
  • 4
  • 34
  • 56
  • Please check that any of your dependencies don't already include android-support-v7-appcompat.jar. Also, you can see on the treeview on the left of the screenshot that there are two android-support-v7 elements. – Quentin S. Dec 29 '14 at 18:54
  • i realize that already. the problem is, i am unable to remove that duplicate jar file from either container. the only option i get is to remove the whole container (Android Dependencies or Android Private Libraries) If you mean that i should delete one from the dexedLibs folder, that doesn't help. They will reappear the next time i compile. They are the executable bytecodes – Abdul Wasae Dec 29 '14 at 19:29
  • 1
    "But i also am unable to remove just this duplicate .jar file from either containers." Why this? Have you tried removing it from both containers, and adding it outside them as a separate library? – Quentin S. Dec 29 '14 at 19:55
  • i just cannot remove it from any container (or both) :( let me try and post screenshot of that or maybe i don't know how to, the correct way. in the builpath window, when i select a jar file, the buttons are greyed out – Abdul Wasae Dec 29 '14 at 20:10
  • @chteuchteu see another screenshot that i added in my post. Also, in the buildpath window, the options are greyed out – Abdul Wasae Dec 29 '14 at 20:18

4 Answers4

23

RESOLVED

bolts-android library was the real trouble here. There were two different versions of it causing a conflict. The FacebookSDK library brings bolts-android-1.1.2, and android-support-v7-appcompat brings bolts-android-1.1.4.

I unmarked Android Private Libraries container in the FacebookSDKlibrary project, which contained bolts-android-1.1.2. As a result, my project now had only one version, bolts-android-1.1.4, settling the conflict. It runs fine now.

Also, turns out, the duplicate android-support-v7-appcompat entries were not an issue.

Abdul Wasae
  • 3,614
  • 4
  • 34
  • 56
  • Yes I found the version mismatch quite suspicious, but what do you mean by unmark... Do you mean remove from build path? – reubenjohn Jan 18 '15 at 19:07
  • Yes. but you know what... i have to unmark it EVERYTIME i open eclipse. :/ haven't fund the solution to this yet :/ i think it is an eclipse bug or something – Abdul Wasae Feb 10 '15 at 19:16
  • 2
    Deleting bolts-android and android-support libraries from main project worked for me. :) – vinesh Mar 25 '15 at 06:43
  • but in my case i wonder why is it that everytime that i open eclipse, it appears again; and i have to delete it again. i have to delete one bolt-android library every time :( – Abdul Wasae Jun 23 '15 at 20:27
  • 1
    removed bolts from my gradle.build fixed it – eggie5 Dec 07 '15 at 16:44
7

i encountered this recently on my react native project, you can go to your android folder of your project . and in terminal hit this command "./gradlew app:dependencies" to see dependencies tree. i found two package for android bolts under facebook sdk . if you exclude this package from facebook sdk things will work fine again

compile ('com.facebook.react:react-native:+') {
   exclude group: 'com.parse.bolts', module: 'bolts-tasks'
}
Hassan Gilak
  • 691
  • 9
  • 14
  • 1
    Thanks Hasan , my issue is the same but with dome different packages. It seems react-native use some different dependency version on 'react-native-firebase-analytics' and 'react-native-fcm' and this different make dexDebug failed on my project. Also using some 'dexOptions' like 'preDexLibraries' very helpful to find wich package has duplicate version. It maybe better solution to change version of these package in package.json to something that match in gradle run instead of excluding some package in main app build.gradle. – Amin Mousavi Oct 21 '16 at 07:52
3

This can happen when adding facebook SDK to Android, you can solve it with:

compile ("com.facebook.android:facebook-android-sdk:4.1.0") {
    exclude group: 'com.parse.bolts', module: 'bolts-android'
}
maraujop
  • 4,472
  • 2
  • 36
  • 40
1

as react version has updated to 0.31.0,when you want to integrate com.facebook.fresco:animated-gif:0.10.0 which has com.parse.bolts has well,you may do like this:

 compile ('com.facebook.react:react-native:+') {
    exclude group: 'com.parse.bolts', module: 'bolts-tasks'
}
compile ('com.facebook.fresco:animated-gif:0.10.0'){
    exclude group: 'com.parse.bolts', module: 'bolts-tasks'
}
fantianwen
  • 21
  • 3