Unable to merge dex in ionic

I fixed it as:

cordova clean android & ionic cordova build android

3 Likes

worked for me, thanks!!

1 Like

same problem here, but I have to solved this problem.
see watch this video tut:
link - AdMobAdsFree Plugin Error - Execution failed for task : 'app.transformClassesWithDesugarForDebug

thank you it worked for me too <3

“cordova clean” is the fix for me

Thanks dvhung95. Your tip helped me.

I removed Barscanner plugin and corresponding npm package
$ ionic cordova plugin rm phonegap-plugin-barcodescanner
$ npm uninstall --save @ionic-native/barcode-scanner

And, also in android/project.properties I had to make this change (essentially removing all specific version numbers and replacing with +):
previously: cordova.system.library.7=com.google.android.gms:play-services-analytics:11.0.1
to: cordova.system.library.7=com.google.android.gms:play-services-analytics:+

How on earth did you figure this out. Thanks for sharing!

2 Likes

Hi all, I encountered this and solved it another way…

Installed Virtualbox and then Ubuntu in it, and then the required nodejs, npm, Ionic, Cordova, java, Android SDK, etc.

And then run the command, no more out of the blue errors as with Windows. Able to build my APK when required now.

1 Like

thnx… work for me… :hugs:

You are the hero we need but don´t deserve…

Hi,

I have the same problem.
None of the above mentioned things have helped me out.
Can anyone please take a look at this and help me out here.

This what it says:

FAILED
35 actionable tasks: 1 executed, 34 up-to-date
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 40s
(node:3136) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 40s
    at ChildProcess.whenDone (C:\Users\Ahsan\Desktop\ConrodProject\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:3136) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:3136) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

And this is my issue thread for all the details of my issue.

NEED HELP.
Thanks.

wow this is worked for me!

  1. Open build.gradle from inside platforms folder.

  2. Find project.ext{} and add multiDexEnabled=true so that it looks like;

    project.ext {
    defaultBuildToolsVersion=“25.0.2” //String
    defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
    defaultTargetSdkVersion=26 //Integer - We ALWAYS target the latest by default
    defaultCompileSdkVersion=26 //Integer - We ALWAYS compile with the latest by default
    multiDexEnabled=true
    }

  3. Save the change and run cordova clean command from your project as;
    myApp$cordova clean

1 Like

I also got this error after adding uk.co.workingedge.phonegap.plugin.launchnavigator plugin… I believe it’s version mismatch. So, how do I check the matching version for my app?
Because I tried many previous versions. No improvements

Thank you, working fine,

worked for me:
cordova clean

Worked for Me Thanks

Single command “cordova clean android” fixed error when building Android Execution failed for task ‘:app:transformDexArchiveWithExternalLibsDexMergerForDebug’.

Thanks so much, Cordova Plugin AdMob Free works perfect now.

cordova clean wasn’t fixing the issue for me.

I had to change platforms/android/project.properties to:
# Project target.
target=android-27
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.system.library.1=com.android.support:support-annotations:27.+
cordova.system.library.2=com.google.android.gms:play-services-analytics:+
cordova.system.library.3=com.google.android.gms:play-services-base:+
cordova.system.library.4=com.google.android.gms:play-services-ads:+

1 Like

thanks, this also worked for me.
@MacOS

Type run cordova clean
instead of ionic cordova clean
then ionic cordova build your-platform