Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple dex files define Landroid/support/annotation/AnimRes #34

Open
kaansoral opened this issue May 21, 2015 · 24 comments
Open

Multiple dex files define Landroid/support/annotation/AnimRes #34

kaansoral opened this issue May 21, 2015 · 24 comments

Comments

@kaansoral
Copy link

com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes

I get this error when building android with the latest cordova

Generally Eddy's version of the plugins have these issues fixed, I hoped the same with this plugin, but it wasn't the case this time :)

The PushPlugin somehow clashes with the libraries of the facebook plugin, my guess is, as removing one of them prevents the issue

@kaansoral
Copy link
Author

It seems the pushplugins use android-support v13 in general and the modified v4 of the facebook sdk conflicts with it, so the issue should probably be solved on that side

@EddyVerbruggen
Copy link

Perhaps the Fb plugin can be changed by scoping the v4 lib to only their classes.

So this line https://github.com/Telerik-Verified-Plugins/Facebook/blob/master/platforms/android/FacebookLib/libs/BUCK#L5

Becomes '//java/com/facebook'. I'd be interested to know if making that change before building the project makes any difference.

@robert-wettstaedt
Copy link

@kaansoral I don't have the Facebook plugin installed but still I get the same Exception when building as you do

@kaansoral
Copy link
Author

I've tested maybe 100 things to combine the v4/v13 android-support usages of the push plugin and the facebook plugin, none worked

Isolating v4 to the facebook plugin makes a lot of sense, yet I'm not fluent enough in java/android/build-logic to achieve that

I just tested the Telerik version of the fb plugin, with android repositories from the android SDK itself, when the fb plugin is added, this is the error: (for this issue, the wizcorp version and your version behave the same, I'm also using your version of the push plugin)
CordovaGCMBroadcastReceiver.java:116: error: cannot find symbol .setColor(getColor(extras)) ^ symbol: method setColor(int) location: class Builder

It probably invalidates the v13 somehow

Both plugins work well without the other, when combined, trying different things just shifts the error and issue to a different one

@kaansoral
Copy link
Author

Eddy, I've just tested the BUCK build solution, however it didn't work, along with many other alternatives I've tried

I might be missing something, but that BUCK file might be ignored, in the end I replaced the entire thing with random characters, the plugin addition from a static directory succeeded

@kaansoral
Copy link
Author

I'm using the telerik versions of the FB/Push plugins

When combined, the error is related to the ".setColor" modification
Removing the FB plugin solves the issue

I've also tested commenting out the ".setColor" routine, in that case the error falls back to the regular dex clash one

I give up temporarily at this point, would be great if you could find a solution to this issue @EddyVerbruggen :)

@EddyVerbruggen
Copy link

Hey @kaansoral, really appreciate the effort. I will take a look shortly!

@kaansoral
Copy link
Author

Not at all, thank _you_
Let me know if you need anything tested :)
I've already spent hours on this issue that I shouldn't have :)

@EddyVerbruggen
Copy link

Hey @kaansoral I've just released an update to this plugin as well as Facebook. Can you update both and give it a shot?

@kaansoral
Copy link
Author

Hi @EddyVerbruggen - thanks a lot! :)

It built and worked well in my limited trials, facebook login was working, gcmregid was present (I didn't yet verified the detailed functionalities of both plugins, but I'm guessing they should work)

I guess I should test the push plugin in detail, as v13 of the pushplugin was replaced with v4, wasn't there any dependency to v13 specifically?

@EddyVerbruggen
Copy link

Yeah there was but I've now added a newer version of v4 to both plugins which cover the same features as the v13 lib we were using (especially the setColor method you tripped over earlier).

@keab42
Copy link

keab42 commented Jul 7, 2015

It's probably better to use the new framework tags to include the support libraries. That way Gradle sorts everything out. I've included that change here: #52

@lalop
Copy link

lalop commented Aug 7, 2015

Hello,
I has the same issue so I tryed with your two plugins ( facebook and pushnotif ) but that resolve nothing for me.
Should I do more than install them via cordova command ?
Thank you

@lalop
Copy link

lalop commented Aug 7, 2015

to follow the answer of @kaansoral here Wizcorp/phonegap-facebook-plugin#1011 (comment)
Here what I just test :

$ cordova create test
$ cd test
$ cordova platform add android
$ cordova plugin add https://github.com/Telerik-Verified-Plugins/Facebook  --variable APP_ID=... --variable APP_NAME="..."
$ cordova run android # all is fine
$ cordova plugin add https://github.com/Telerik-Verified-Plugins/PushNotification
$ cordova run android # error

@kaansoral
Copy link
Author

Interesting, What is the exact error?

Updating the android SDK's and installing static repositories might also help (they are an optional add-on, forgot the exact name, but sometimes if things are missing they are fetched dynamically from maven, it's best to just install them from the Android SDK instead)

@lalop
Copy link

lalop commented Aug 7, 2015

Here is the end of the build

:compileDebugJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:preDexDebug
:dexDebug

UNEXPECTED TOP-LEVEL EXCEPTION:
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:454)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
    at com.android.dx.command.dexer.Main.run(Main.java:246)
    at com.android.dx.command.dexer.Main.main(Main.java:215)
    at com.android.dx.command.Main.main(Main.java:106)

:dexDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /Users/sam/Library/android-sdk-macosx/build-tools/22.0.1/dx --dex --no-optimize --output /Users/sam/Workspace/projets/Clint/saysi/mobile/test/platforms/android/build/intermediates/dex/debug --input-list=/Users/sam/Workspace/projets/Clint/saysi/mobile/test/platforms/android/build/intermediates/tmp/dex/debug/inputList.txt
  Error Code:
    2
  Output:

    UNEXPECTED TOP-LEVEL EXCEPTION:
    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:454)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
        at com.android.dx.command.dexer.Main.run(Main.java:246)
        at com.android.dx.command.dexer.Main.main(Main.java:215)
        at com.android.dx.command.Main.main(Main.java:106)



* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

I'm building my first app with cordova, not sure about how to know if I have something to update, in the android sdk manager nothing is marked as "has update".
What is a static repository ?

@kaansoral
Copy link
Author

They are in the "Extras" section of "Android SDK Manager"

They are called "Google Repository", "Google Support Repository", "Google Support Library" etc.

@lalop
Copy link

lalop commented Aug 7, 2015

They are installed

@lalop
Copy link

lalop commented Aug 7, 2015

Oh no I have "Google Repository", "Android Support Repository", "Android Support Library" but I assume it's what you mean isn't it ?

@kaansoral
Copy link
Author

Yes they are what I meant, in this case, I have no idea what's wrong with your build

I'm on OSX by the way

@lalop
Copy link

lalop commented Aug 7, 2015

So am I :(

@lalop
Copy link

lalop commented Aug 7, 2015

Problem solved,
I removed and reinstall the android sdk, create a new app and that work.
Thank you @kaansoral for your time

@kaansoral
Copy link
Author

No problem, it's a very interesting solution

Unfortunately these kind of library clash issues have been very frequent lately, watch out for the google analytics plugin one, it's only easily solveable by manually reverting that plugin to an older state

@JWesorick
Copy link

After adding this plugin I'm getting this error:
Multiple dex files define Landroid/support/annotation/AnimRes;
Any news on how to fix it?

Also here is my full plugin list if it helps.

cc.fovea.cordova.purchase 3.11.0 "Purchase"
com.google.playservices 19.0.0 "Google Play Services for Android"
com.ionic.keyboard 1.0.4 "Keyboard"
com.phonegap.plugins.PushPlugin 2.5.8 "PushPlugin"
com.phonegap.plugins.facebookconnect 0.11.2 "Facebook"
com.verso.cordova.clipboard 0.1.0 "Clipboard"
cordova-plugin-camera 1.2.0 "Camera"
cordova-plugin-console 1.0.1 "Console"
cordova-plugin-crosswalk-webview 1.2.0 "Crosswalk WebView Engine"
cordova-plugin-device 1.0.1 "Device"
cordova-plugin-file 2.1.0 "File"
cordova-plugin-file-transfer 1.2.0 "File Transfer"
cordova-plugin-geolocation 1.0.1 "Geolocation"
cordova-plugin-google-analytics 0.7.1 "Google Universal Analytics Plugin"
cordova-plugin-inappbrowser 1.0.1-dev "InAppBrowser"
cordova-plugin-network-information 1.0.1 "Network Information"
cordova-plugin-splashscreen 2.0.1-dev "Splashscreen"
cordova-plugin-statusbar 1.0.1 "StatusBar"
cordova-plugin-whitelist 1.0.0 "Whitelist"
org.apache.cordova.globalization 0.3.4 "Globalization"
twitter-connect-plugin 0.4.0 "Twitter Connect"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants