Cordova Error on Build Only for Android: com.andro

2019-03-09 02:45发布

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

3条回答
放我归山
2楼-- · 2019-03-09 03:23

This is almost definitely because of conflicting plugins. The way I solved it (I hope you're sitting comfortably) was to remove every single plugin, then add each of them one by one and try building. As far as I can see, that's the only real way to diagnose these.

Usually it's dependencies on some sort of Google library (play services or location), so I'd say the most likely culprits are plugins involved in location or push notifications.

查看更多
戒情不戒烟
3楼-- · 2019-03-09 03:24

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.

查看更多
ゆ 、 Hurt°
4楼-- · 2019-03-09 03:35

This worked for me:

Just delete "build" folder inside platforms/android then run cordova build android. For me its worked

查看更多
登录 后发表回答