每当我尝试构建自己的cordova应用程序时,都会出现此错误:
:mergeArmv7DebugAssets UP-TO-DATE
:createXwalkCommandLineFileArmv7Debug
:generateArmv7DebugResValues UP-TO-DATE
:generateArmv7DebugResources UP-TO-DATE
:mergeArmv7DebugResources
:processArmv7DebugManifest
:processArmv7DebugResources
:generateArmv7DebugSources
:compileArmv7DebugJava
:preDexArmv7Debug
:dexArmv7DebugUNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode;
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):dexArmv7Debug FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ‘:dexArmv7Debug’.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Users/sombriks/Library/Android/sdk/build-tools/22.0.1/dx –dex –no-optimize –output /Users/sombriks/git/g4l-taxi/platforms/android/build/intermediates/dex/armv7/debug –input-list=/Users/sombriks/git/g4l-taxi/platforms/android/build/intermediates/tmp/dex/armv7/debug/inputList.txt
Error Code:
2
Output:UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode;
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
Total time: 27.511 secs
/Users/sombriks/git/g4l-taxi/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^Error code 1 for command: /Users/sombriks/git/g4l-taxi/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/sombriks/git/g4l-taxi/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/sombriks/git/g4l-taxi/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/sombriks/git/g4l-taxi/platforms/android/cordova/build: Command failed with exit code 8at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134: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)
[sombriks@eiko g4l-taxi]$
这是我的插件列表:
[sombriks@eiko g4l-taxi]$cordova plugin list
cordova-plugin-admobpro 2.8.1 “AdMob Plugin Pro”
cordova-plugin-crosswalk-webview 1.2.0 “Crosswalk WebView Engine”
cordova-plugin-extension 1.1.4 “Cordova Plugin Extension”
cordova-plugin-googleplayservices 19.0.1 “Google Play Services for Android”
cordova-plugin-whitelist 1.0.0 “Whitelist”
org.apache.cordova.console 0.2.13 “Console”
只有android内部版本显示此问题,ios内部版本会编译并运行.
一些other posts建议修改我的build.gradle,但到目前为止没有任何效果.
如果以前有人遇到过此类问题,请提供帮助.
提前致谢.
编辑:
创建一个新项目并仅添加crosswalk plugin给我一个可以正常工作的项目,包括android和ios.我将添加更多插件,看看会发生什么.
解决方法:
cordova-plugin-googleplayservices 19.0.1“适用于Android的Google Play服务”
删除此插件,它已被弃用,不再需要.
请参阅常见问题3:https://github.com/floatinghotpot/cordova-admob-pro/wiki/Difference-of-Plugin-IDs