Thursday, September 24, 2015

Cordova / Ionic - Multiple Dex Issue with "Facebook Connect" and "LocalNotification" plugins.

Had a problem with Cordova / Ionic today:

com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)

After some hours of reading and testing found solution that worked for me in following configuration:

com.phonegap.plugins.facebookconnect 0.11.0 "Facebook Connect"
de.appplant.cordova.plugin.local-notification 0.8.2-dev "LocalNotification"

Fix was quite simple (after a couple of hours :) :

plugins/com.phonegap.plugins.facebookconnect/plugin.xml:

-   <framework custom="true" src="platforms/android/FacebookLib">
+   <framework src="com.android.support:support-v4:+">
+   <framework src="com.facebook.android:facebook-android-sdk:3.23.0">

plugins/de.appplant.cordova.plugin.local-notification/plugin.xml:

-   <dependency id="cordova-plugin-android-support-v4">
+   <framework src="com.android.support:support-v4:+">


PS: de.appplant.cordova.plugin.local-notification will install cordova-plugin-android-support-v4 - you can remove it after this with ionic plugin remove cordova-plugin-android-support-v4

No comments: