android - 错误 : Multiple dex files define Landroid/support/annotations/AnimRes with Admob and Facebook Cordova plugins

标签 android cordova jar ionic-framework

我正在使用 cordova 和 Ionic 框架构建应用程序。

但是现在当我构建我的项目时遇到了错误:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/annotations/AnimRes;

其他 SO 解决方案提到多个 android-support-v4.jar 文件冲突,但是我能找到的唯一 android-support-v4.jar 文件在 facebook 中插件。

另一个解决方案提到了版本冲突(即 android-support-v4.jarandroid-support-v13.jar 冲突)——同样,我看不到任何对android-support-v13.jar 在我的项目中。

另一个解决方案是 android-support-annotations.jarandroid-support-v4.jar 冲突:multiple dex files define landroid/support/annotation/AnimRes。我在我的项目中找不到任何 android-support-annotations.jar 文件,除了在以下位置创建的文件:myProject\platforms\android\build\intermediates\pre-dexed\debug enter image description here

但是我不明白这是如何创建的。

我该如何解决这个问题?问题很容易重现:

>ionic start myApp tabs
>cd myApp
>cordova plugin add https://github.com/Wizcorp/phonegap-facebook-plugin.git --variable APP_ID="123456789" --variable APP_NAME="myApplication"
>cordova plugin add cordova-plugin-admobpro
>ionic platform android
>ionic build android 

(其中 APP_ID 和 APP_NAME 是 facebook 应用程序的 ID 和名称)

最佳答案

您需要排除 Wizcorp Facebook 插件包含的 android-support-v4.jar。技巧很简单,您需要在 platforms/android 中创建 build-extras.gradle 并添加以下内容:

配置{ all*.exclude 组:'com.android.support',模块:'support-v4' }

就是这样,现在每个使用 android 支持库的插件都可以使用这个 FB 插件。 你可能会把它放在默认的 build.gradle 中的某个地方,但我不知 Prop 体在哪里,这个 build-extras 文件会自动包含,所以它很好。

关于android - 错误 : Multiple dex files define Landroid/support/annotations/AnimRes with Admob and Facebook Cordova plugins,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32099385/

相关文章:

java - 这个 .jar 文件有什么问题?

android - 在 PagerAdapter/ViewPager 中禁用手势

javascript - 在Firefox中关闭/隐藏Android软键盘

android - 在 Cordova 点击文本框后显示顶部和底部菜单

cordova - 如何在 Eclipse 中开始使用 PhoneGap?

JAR 文件中的 Java 图像缩放质量丢失

android - 如何在 Flutter 中创建 ListTile 列表?

android - java.lang.IllegalArgumentException : Invalid speaker model provided 异常

ios - Phonegap KeyboardShrinksView 和固定在 iOS 上的位置应用不正确

java - 导入JAR文件时出现`error: Could not deserialize`