3
votes

whenever i try to build my cordova app i got this error:

:mergeArmv7DebugAssets UP-TO-DATE :createXwalkCommandLineFileArmv7Debug :generateArmv7DebugResValues UP-TO-DATE :generateArmv7DebugResources UP-TO-DATE :mergeArmv7DebugResources :processArmv7DebugManifest :processArmv7DebugResources :generateArmv7DebugSources :compileArmv7DebugJava :preDexArmv7Debug :dexArmv7Debug

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)

: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 8

at 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]$

here comes my plugin list:

[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"

Only the android build shows this issue, ios build compiles and runs.

some other posts suggests to modify my build.gradle, but it had no effect so far.

If anyone had faced such problem before, please help.

Thanks in advance.

EDIT:

Creating a fresh project and adding just the crosswalk plugin gives me an working project, both android and ios. I'll add more plugins and see what happens.

2

2 Answers

3
votes

cordova-plugin-googleplayservices 19.0.1 "Google Play Services for Android"

Remove this plugin, it's deprecated and no more needed.

See FAQ 3: https://github.com/floatinghotpot/cordova-admob-pro/wiki/Difference-of-Plugin-IDs

0
votes

Ok, if anyone else runs on such kind of problem, here's my solution:

  1. Back up your www folder
  2. Update npm
    • sudo yum update npm
  3. Update cordova
    • sudo npm -g install cordova
  4. Create a brand new project
    • codrova create MyFolder my.namespace "My Title"
  5. Bring your www folder back
  6. Add all your plugins back:
    • cordova plugin add cordova-plugin-console
    • cordova plugin add cordova-plugin-crosswalk-webview
    • cordova-plugin-admobpro
  7. Add your platforms back:
    • cordova platform add android
    • cordova platform add ios

The issue is gone and seems to be related to the age of this project. I've faced one or two cordova versios update, no telling how much updates each plugin had.

In the end, keep the environment updated and clean could solve it.