18

我确实知道之前已经多次报告过多个 dex 问题,但在我的情况下似乎没有一个解决方案有效。

安慰:

    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;

一种流行的解决方案是从 buildpath 中取消标记“Android 私有库”容器。我不能这样做,因为该容器中还有一些我需要的库。

另一个解决方案是取消标记以 .jar 形式显式添加的任何重复库。我没有这样的图书馆。

在我的情况下,重复库是:android-support-v7-appcompat.jar 我在这两个容器中拥有它(直接从 sdk 文件夹中引用):

1.) Android 私有库

2.) Android 依赖项

问题是我不能完全取消这两个容器中的任何一个,因为它们都包含其他必要的库。但我也无法从任一容器中删除这个重复的 .jar 文件。

编辑: 注意当我将 android-support-v7-appcompat library_project 添加到我的项目中时,它会进入两个容器。必须有某种方式,以便只进入一种方式。

任何人都可以帮助我如何做到这一点?

截屏

截图2(无法删除)

4

4 回答 4

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.

于 2014-12-29T20:43:48.847 回答
7

我最近在我的 react native 项目中遇到了这个问题,你可以去你项目的 android 文件夹。并在终端中点击此命令“./gradlew app:dependencies”以查看依赖关系树。我在 facebook sdk 下找到了两个用于 android bolts 的包。如果你从 facebook sdk 中排除这个包,事情会再次正常工作

compile ('com.facebook.react:react-native:+') {
   exclude group: 'com.parse.bolts', module: 'bolts-tasks'
}
于 2016-08-20T14:16:34.923 回答
3

将 facebook SDK 添加到 Android 时可能会发生这种情况,您可以通过以下方式解决:

compile ("com.facebook.android:facebook-android-sdk:4.1.0") {
    exclude group: 'com.parse.bolts', module: 'bolts-android'
}
于 2017-01-25T07:39:21.590 回答
1

由于 react 版本已经更新到 0.31.0,当你想集成com.facebook.fresco:animated-gif:0.10.0哪个com.parse.bolts已经很好的时候,你可以这样做:

 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'
}
于 2016-11-03T09:53:02.290 回答