Unable to execute dex: Multiple dex files define Lbolts/AggregateException
Asked Answered
M

4

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)

Merodach answered 29/12, 2014 at 18:52 Comment(5)
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.Whatsoever
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 bytecodesMerodach
"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?Whatsoever
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 outMerodach
@chteuchteu see another screenshot that i added in my post. Also, in the buildpath window, the options are greyed outMerodach
M
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.

Merodach answered 29/12, 2014 at 20:43 Comment(5)
Yes I found the version mismatch quite suspicious, but what do you mean by unmark... Do you mean remove from build path?Thimerosal
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 somethingMerodach
Deleting bolts-android and android-support libraries from main project worked for me. :)Traumatize
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 :(Merodach
removed bolts from my gradle.build fixed itUnset
R
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'
}
Rains answered 20/8, 2016 at 14:16 Comment(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.Lehmann
T
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'
}
Tetragram answered 25/1, 2017 at 7:39 Comment(0)
R
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'
}
Roundfaced answered 3/11, 2016 at 9:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.