I'm building an app using cordova and the Ionic framework.
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 only android-support-v4.jar
file I can find is within the facebook plugin.
Another solution mentioned conflicting versions (i.e android-support-v4.jar
conflicting with android-support-v13.jar
) - again, I cannot see any references to android-support-v13.jar
within my project.
Another solution was conflicting android-support-annotations.jar
and android-support-v4.jar
: multiple dex files define landroid/support/annotation/AnimRes . I cannot find any android-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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With