仅适用于Android的Cordova错误:com.android.dex.DexException:多个dex文件定义Landroid / support / annotation / AnimRes; [英] Cordova Error on Build Only for Android: com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;

查看:92
本文介绍了仅适用于Android的Cordova错误:com.android.dex.DexException:多个dex文件定义Landroid / support / annotation / AnimRes;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跟着关于这个问题的另外三个资源,但没有一个工作。

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

我的iOS构建完美,但无论我尝试改变什么,android都会出现此错误。

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


  • 已经尝试创建一个新项目但是android保持了同样的问题。

  • 所有Android SDK的已安装

以下是错误:

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.

我感谢任何类型的帮助

推荐答案

出现同样的问题,将以下行添加到位于platforms / android的build.gradle文件中为我做了。

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

我在行后复制了它:

apply plugin: 'android'

希望这有帮助。

这篇关于仅适用于Android的Cordova错误:com.android.dex.DexException:多个dex文件定义Landroid / support / annotation / AnimRes;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆