How do I resolve a failing release build with transform-Dex-Archive-With-Dex-Merger... error?

  • ionic cordova build: works.
  • ionic cordova build --prod: works.
  • ionic cordova build --prod --release: fails with error:
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerForRelease'.
> java.lang.RuntimeException: java.lang.RuntimeException: Error while merging dex archives: 
  Learn how to resolve the issue at
  Program type already present: org.apache.cordova.BuildHelper

I’ve read all the other questions here on this, nothing seems to work.
Anyone please help me? Thanks.
(please don’t just mark as duplicate!)

Things I’ve tried:

  • reinstalling node
  • reinstalling ionic + cordova
  • re adding the android project (having deleted node_modules + plugins)
  • adding plugin: cordova-plugin-androidx
  • then adding plugin: cordova-plugin-androidx-adapter
  • cordova clean android

Here’s my ionic info output:


   Ionic CLI          : 5.4.1 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.4


   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, (and 15 other plugins)


   cordova-res : 0.6.0 
   native-run  : 0.2.8 


   ios-deploy : 1.9.2
   ios-sim    : 5.0.8
   NodeJS     : v10.16.3 (/usr/local/bin/node)
   npm        : 6.9.0
   OS         : macOS Mojave
   Xcode      : Xcode 10.3 Build version 10G8

Here’s my file:

# Project target.

Here’s my build.gradle file:

buildscript {
    repositories {

    dependencies {
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

        classpath ''

allprojects {
    repositories {

    //This replaces w.r.t. build settings
    project.ext {
      defaultBuildToolsVersion="28.0.3" //String
      defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
      defaultTargetSdkVersion=28 //Integer - We ALWAYS target the latest by default
      defaultCompileSdkVersion=28 //Integer - We ALWAYS compile with the latest by default

task clean(type: Delete) {
    delete rootProject.buildDir

Hey, did you solve this? I’ve got very similar situation here. Please tel me know

Sorry to say no. I was trying to update a V3 Ionic project and all its dependencies to their latest versions, but in the end I rolled everything back and abandoned updating my entire project.

Maintaining a project with separately written Cordova plugins sure is a pain in the ass. I’m done with it.