错误:多个dex文件定义与Admob和Facebook Cordova插件的Landroid /支持/注释/ AnimRes [英] Error: Multiple dex files define Landroid/support/annotations/AnimRes with Admob and Facebook Cordova plugins
问题描述
我正在使用cordova和Ionic框架构建应用程序。
- 我使用的是Wizcorp facebook插件:
但是我不明白这是如何创建的。
我如何解决这个问题?该问题很容易被复制:
> 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插件add cordova-plugin- admobpro
> ionic platform android
> ionic build android
APP_ID和APP_NAME是Facebook应用程式的ID和名称)
解决方案您需要排除android-support-v4.jar被Wizcorp Facebook插件包括。 Trick很简单,你需要在platforms / android中创建
build-extras.gradle
并添加以下内容:
configurations {
all * .exclude group:'com.android.support',module:'support-v4'
}
就是这样,现在每个使用android支持lib的插件都会使用这个FB插件。
你可能把这个在默认build.gradle的某个地方,但我无法弄清楚在哪里,这个build-extras文件获得自动包括所以它的罚款。I'm building an app using cordova and the Ionic framework.
- I'm using the Wizcorp facebook plugin:
https://github.com/Wizcorp/phonegap-facebook-plugin . - and I recently added the google admob plugin:
https://github.com/floatinghotpot/cordova-admob-pro
However now when I build my project I'm met with the error:
UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/annotations/AnimRes;
Other SO solutions mention multiple
android-support-v4.jar
files conflicting, however the onlyandroid-support-v4.jar
file I can find is within the facebook plugin.Another solution mentioned conflicting versions (i.e
android-support-v4.jar
conflicting withandroid-support-v13.jar
) - again, I cannot see any references toandroid-support-v13.jar
within my project.Another solution was conflicting
android-support-annotations.jar
andandroid-support-v4.jar
: multiple dex files define landroid/support/annotation/AnimRes . I cannot find anyandroid-support-annotations.jar
files within my project, except something that is created in:myProject\platforms\android\build\intermediates\pre-dexed\debug
However I don't understand how this is getting created.
How can I solve this problem? The problem can be easily reproduced:
>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
(where APP_ID and APP_NAME are the ID and name of a facebook application)
解决方案You need to exclude android-support-v4.jar that got included by Wizcorp Facebook plugin. Trick is simple you need to create
build-extras.gradle
inside platforms/android and add following:configurations { all*.exclude group: 'com.android.support', module: 'support-v4' }
And that's it, now every plugin that uses android support lib will work with this FB plugin. You could probably put this somewhere in default build.gradle but i couldn't figure out exactly where, this build-extras file get auto included so its fine.
这篇关于错误:多个dex文件定义与Admob和Facebook Cordova插件的Landroid /支持/注释/ AnimRes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- I'm using the Wizcorp facebook plugin: