Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova - Multiple dex files define (annotation)

I'm working on a project with ionic. After I installed the Facebook Plugin I'm not able to build the project for android anymore!

The command

ionic build android

gives me this error message

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

I'm reading a lot of tutorials/answers about this error and it seems to be related to the use of the Facebook Plugin with the Push Notification Plugin.

It's two days I'm trying a lot of different solutions, but none of those is working :(

Here are some information about my configuration:

plugin com.phonegap.plugins.PushPlugin version 2.5.0
plugin com.phonegap.plugins.facebookconnect version 0.11.0 (installed with the local repository, as indicated on github)
cordova version 5.0
ionic version 1.6.3

It looks like this problem is related to the "support-annotations" library loaded several times. Buy I really don't know how this is possible and where I can check it.

Can you help me? Do you have any idea of how to make this working? Is there a ionic/cordova configuration file where I can check the dependencies?

Thanks a lot in advance.

like image 704
98problems Avatar asked Jul 30 '15 15:07

98problems


Video Answer


2 Answers

Multiple dex files error is raised because of using multiple support jar files in the ionic / cordova project

you need to change build.gradle under platforms/android

find the below line

apply plugin:'com.android.application'

after add these below lines

configurations {
   all*.exclude group: 'com.android.support', module: 'support-v4'
} 
like image 101
Jagadeesh Avatar answered Sep 19 '22 12:09

Jagadeesh


i solved same problem in my app the problem is

 com.android.support:support-v4:+

com.android.support:support-v4:+ file exist in /platforms/android/phonegap-facebook-plugin/Myapp-FacebookLib/libs

if you want only used facebook and Push Notification Plugin then simply commit the line in project.properties

#cordova.system.library.1=com.android.support:support-v4:+

Best way to solved this problem

1 First delete the android-support-v4.jar from /platforms/android/phonegap-facebook-plugin/Myapp-FacebookLib/libs

2 second step create a file name build-extras.gradle in /platforms/android/phonegap-facebook-plugin/Myapp-FacebookLib/

and type in file

dependencies {
compile "com.android.support:support-v4:+" }
like image 30
Anurag Pandey Avatar answered Sep 20 '22 12:09

Anurag Pandey