Android build error - Execution failed for task app:transformDexWithDexForRelease


I have been stuck at this issue for a few hours trying to fix this issue but unable to find a solution. I really need some help here. I ran the command below to build

ionic cordova build android --release --aot --prod

and got this

* What went wrong:
Execution failed for task ':app:transformDexWithDexForRelease'.
> java.util.concurrent.ExecutionException: Multiple dex files define Lcom/google/android/gms/internal/measurement/zzxk;

Without using --release, it shows a different error:

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: Unable to merge dex

I have tried a few suggestions in other threads and forums but they don’t work. Some examples:

cordova clean android
cordova build android

This is my ionic info:

ionic info

cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 8.0.0 

local packages:

@ionic/app-scripts : 3.1.8
Cordova Platforms  : android 7.0.0 ios 4.5.1
Ionic Framework    : ionic-angular 3.9.2


Android SDK Tools : 26.1.1
ios-deploy        : 1.9.2 
ios-sim           : 3.1.1 
Node              : v9.4.0
npm               : 5.6.0 
OS                : macOS High Sierra
Xcode             : Xcode 9.4.1 Build version 9F2000 

Here is my plugin list

cordova-android-firebase-gradle-release 1.0.2 "cordova-android-firebase-gradle-release"
cordova-android-play-services-gradle-release 1.4.3 "cordova-android-play-services-gradle-release"
cordova-android-support-gradle-release 1.4.4 "cordova-android-support-gradle-release"
cordova-plugin-advanced-http 1.11.1 "Advanced HTTP plugin"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-firebase 1.0.5 "Google Firebase Plugin"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-ionic-webview 1.2.1 "cordova-plugin-ionic-webview"
cordova-plugin-mauron85-background-geolocation 2.3.5 "CDVBackgroundGeolocation"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.4.1 "StatusBar"
cordova-plugin-whitelist 1.3.1 "Whitelist"
cordova-sqlite-storage 2.2.0 "Cordova sqlite storage plugin"
ionic-plugin-keyboard 2.2.1 "Keyboard"

I am using the gradle release as it seems the background location and firebase plugin is conflicting. The versions set via those plugins are:

| cordova-android-firebase-gradle-release: 15.+



| cordova-android-play-services-gradle-release: 15.+



| cordova-android-support-gradle-release: 27.+


I have also updated my packages using but I still encounter that issue. Please help! :cry:


@arsyad did you ever resolve?


I’m experiencing the exact same errors. Any fix yet?


For my project, I notice that those errors when I started using these plugins:


The reason why I used those 3 plugins is because some plugins seems to use different Android Support Library and Google Play Services version. And I tried to correct it with those plugins.

Mine specifically had to do with the background geolocation plugin which I set a version for the Android Support Library and Google Play services that seems to be incompatible with another plugin (i.e Firebase). So instead, I removed the 3 plugins, and checked that all the plugins I used match the same Android Support Library and Google Play Services. And that resolved my issue.


The cause of my issues was a conflict between facebook4 and phonegap barcode scanner. SDK and API version conflicts between them both. Finally fixed by rolling back facebook4.


android {

defaultConfig {
    multiDexEnabled true

cordova clean cordova build