1

os: OSX 10.11 cordova: 5.4.1 (also tried on 6.0) node: 4.2.6 cordova plugins used: crosswalk-project/cordova-plugin-crosswalk-webview (1.5), phonegap/phonegap-plugin-push (1.5.3), and dariosalvi78/cordova-plugin-health (0.5.3)

when running cordova build android I receive the following error

  • What went wrong: Executi on failed for task ':dexArmv7Debug'. com.android.ide.common.internal.LoggedErrorException: Failed to run command: /usr/local/Cellar/android-sdk/24.4.1_1/build-tools/23.0.2/dx --dex --no-optimize --output /Users/simon/projects/SproutMobile/platforms/android/build/intermediates/dex/armv7/debug --input-list=/Users/simon/projects/SproutMobile/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/android/gms/internal/zzpz$zza;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
    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)

*

manually applying the suggested fix from Multiple dex files define Lcom/google/android/gms/internal/zzau to platforms/android/build.gradle did not change anything.

Any help would be greatly appreciated

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47

1 Answers1

0

I had a similar problem after building using phonegap/cordova: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzsk;

Check in your build.gradle(module Android), if you have 2 libraries that should have the exact same version with different version numbers. In my case it was play-services-gms:8.4.0 and play-services-location:9.2.1.

Here is my updated build.gradle:

dependencies{
....
//make sure are both same version (8.4.0 or 9.2.1 in my case)
compile 'com.google.android.gms:play-services-gcm:9.2.1'
// this is the one I changed:  compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-location:9.2.1' // it was 8.4.0
....
}
rafahoro
  • 1,237
  • 13
  • 19