Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova Error on Build Only for Android: com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;

I followed another three resources about this issue, but none worked.

My iOS builds perfectly, but the android gives this error no matter what i try to change.

  • Already tried to create a new project but android keeps the same issue.
  • All Android SDK's are installed

Here follows the error:

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/sakai/Library/Android/sdk/build-tools/23.0.1/dx --dex --no-optimize --output /Users/sakai/mobile/cupomap/platforms/android/build/intermediates/dex/debug --input-list=/Users/sakai/mobile/cupomap/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: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)
  	


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

BUILD FAILED

Total time: 5.343 secs

/Users/sakai/mobile/cupomap/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: /Users/sakai/mobile/cupomap/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/sakai/mobile/cupomap/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/sakai/mobile/cupomap/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /Users/sakai/mobile/cupomap/platforms/android/cordova/build: Command failed with exit code 8
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:756:16)
    at Process.ChildProcess._handle.onexit (child_process.js:823:5)

A Lot of resources says that it's mostly an duplicated support file with different versions. So here follow's my Plugins List

com.googlemaps.ios 1.9.2 "Google Map iOS SDK for Cordova"
cordova-plugin-console 1.0.1 "Console"
cordova-plugin-device 1.0.1 "Device"
cordova-plugin-device-motion 1.1.1 "Device Motion"
cordova-plugin-device-orientation 1.0.1 "Device Orientation"
cordova-plugin-dialogs 1.1.1 "Notification"
cordova-plugin-geolocation 1.0.1 "Geolocation"
cordova-plugin-splashscreen 2.1.0 "Splashscreen"
cordova-plugin-statusbar 1.0.1 "StatusBar"
cordova-plugin-whitelist 1.0.0 "Whitelist"
phonegap-plugin-push 1.2.2 "PushPlugin"
plugin.google.maps 1.2.9 "phonegap-googlemaps-plugin"
plugin.http.request 1.0.4 "phonegap-http-request"

I've been trying to solve this for almost a day now.

I appreciate any type of help

like image 585
Sakai Avatar asked Sep 10 '15 20:09

Sakai


1 Answers

Had the same problem, adding the following lines to the build.gradle file located in platforms/android did it for me.

configurations {
   all*.exclude group: 'com.android.support', module: 'support-v4'
}

I copied it after the line:

apply plugin: 'android'

Hope this helps.

like image 105
henkie14 Avatar answered Nov 15 '22 22:11

henkie14