Ionic build android - isse Multiple dex files define Lcom/google/android/gcm/GCMBaseIntentService


#1

Hey guys,

So I’ve been pretty successful building apps on iOS. Today, I wanted to test my app on android device. However, Ive been unsuccessful - when I run a build command for android, I receive the following:

Running command: /Volumes/SSD/Users/Lukasz/Desktop/app/hooks/after_prepare/010_add_platform_class.js /Volumes/SSD/Users/Lukasz/Desktop/app
add to body class: platform-android
Running command: /Volumes/SSD/Users/Lukasz/Desktop/app/hooks/after_prepare/020_remove_sass_from_platforms.js /Volumes/SSD/Users/Lukasz/Desktop/app
Running command: /Volumes/SSD/Users/Lukasz/Desktop/app/platforms/android/cordova/build
ANDROID_HOME=/Users/Lukasz/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
Running: /Volumes/SSD/Users/Lukasz/Desktop/app/platforms/android/gradlew cdvBuildDebug -b /Volumes/SSD/Users/Lukasz/Desktop/app/platforms/android/build.gradle -Dorg.gradle.daemon=true
:preBuild
:compileDebugNdk UP-TO-DATE
:preDebugBuild
:checkDebugManifest
:CordovaLib:compileLint
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles UP-TO-DATE
:CordovaLib:preBuild
:CordovaLib:preDebugBuild
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:compileDebugJava UP-TO-DATE
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:packageDebugJar UP-TO-DATE
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:packageDebugJniLibs UP-TO-DATE
:CordovaLib:packageDebugLocalJar UP-TO-DATE
:CordovaLib:packageDebugRenderscript UP-TO-DATE
:CordovaLib:bundleDebug UP-TO-DATE
:prepareAndroidCordovaLibUnspecifiedDebugLibrary UP-TO-DATE
:prepareDebugDependencies
:compileDebugAidl UP-TO-DATE
:compileDebugRenderscript UP-TO-DATE
:generateDebugBuildConfig UP-TO-DATE
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets
:generateDebugResValues UP-TO-DATE
:generateDebugResources UP-TO-DATE
:mergeDebugResources UP-TO-DATE
:processDebugManifest UP-TO-DATE
:processDebugResources
:generateDebugSources
:compileDebugJavaNote: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

:preDexDebug
:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gcm/GCMBaseIntentService;
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)

FAILED

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/Lukasz/Library/Android/sdk/build-tools/22.0.1/dx --dex --no-optimize --output /Volumes/SSD/Users/Lukasz/Desktop/app/platforms/android/build/intermediates/dex/debug --input-list=/Volumes/SSD/Users/Lukasz/Desktop/app/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 Lcom/google/android/gcm/GCMBaseIntentService;
	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: 1 mins 20.991 secs

/Volumes/SSD/Users/Lukasz/Desktop/app/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Volumes/SSD/Users/Lukasz/Desktop/app/platforms/android/gradlew with args: cdvBuildDebug,-b,/Volumes/SSD/Users/Lukasz/Desktop/app/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Volumes/SSD/Users/Lukasz/Desktop/app/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /Volumes/SSD/Users/Lukasz/Desktop/app/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:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)

This is the versions that I am using :
Ionic: 1.3.2
Cordova 5.1.1
Java: latest 8.45

Any ideas on what could go wrong?


#2

I just started getting the same issue after installing PushPlugin. Uninstalling it removes the build error, but I need it, so will have to keep digging.


#3

The same error also with PushPlugin ¿?¿?¿

Cordova CLI: 5.1.1
Ionic Version: 1.0.0-rc.0
Ionic CLI Version: 1.6.1
Ionic App Lib Version: 0.3.3
ios-deploy version: Not installed
ios-sim version: 3.1.1
OS: Mac OS X Yosemite
Node Version: v0.12.7
Xcode version: Xcode 6.4 Build version 6E35b


#4

Hi, I know it has been quite some time but did anyone found the answer to this? I’m getting the same error with another plugin (usbserial)