Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
335 views
in Technique[技术] by (71.8m points)

android - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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'
} 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...