Unable to execute dex: Multiple dex files define L

2019-01-22 07:45发布

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)

4条回答
ら.Afraid
2楼-- · 2019-01-22 08:20

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'
}
查看更多
萌系小妹纸
3楼-- · 2019-01-22 08:21

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'
}
查看更多
等我变得足够好
4楼-- · 2019-01-22 08:26

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'
}
查看更多
贼婆χ
5楼-- · 2019-01-22 08:35

SOLVED SOMEHOW

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.

查看更多
登录 后发表回答