Mohanraj
Mohanraj

Reputation: 326

How to fix unable merge with dex in ionic?

I’m getting issue follow while taking android build.

Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug’

Task :CordovaLib:compileDebugShaders UP-TO-DATE Task :CordovaLib:generateDebugAssets UP-TO-DATE Task :CordovaLib:packageDebugAssets UP-TO-DATE Task :app:mergeDebugAssets Task :app:validateSigningDebug UP-TO-DATE Task :app:signingConfigWriterDebug UP-TO-DATE Task :app:transformClassesWithDexBuilderForDebug UP-TO-DATE

Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED D8: Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver

FAILURE: Build failed with an exception.

BUILD FAILED in 22s 35 actionable tasks: 3 executed, 32 up-to-date /Users/panmoh/Documents/mobile-app/platforms/android/gradlew: Command failed with exit code 1 Error output: D8: Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver

FAILURE: Build failed with an exception.

BUILD FAILED in 22s [ERROR] An error occurred while running subprocess cordova.

    cordova build android exited with exit code 1.

    Re-running this command with the --verbose flag may provide more information.

Note : I tried cordova clean android and remove and add android platfoem as well

Upvotes: 3

Views: 2477

Answers (3)

Akshay
Akshay

Reputation: 21

The solution accepted here is the true solution. I stuck with this issue for a week and than on last weekend i decided no matter what happens a'll find solution for it.

All credit goes to this person named (ProdoElmit) who answered it here.

Attaching screenshots for above solution to make it easier to follow: gradlew.bat tasks --all

gradlew.bat yourproject:dependencies Here my project name was app

In my case it was FCM which was using androidx and causing this issue. Hope this will help someone to resolve their issue as well. enter image description here

Upvotes: 0

MedMatrix
MedMatrix

Reputation: 336

To fix this issue for those using Phonegap/Cordova

  • Install the “cordova-plugin-androidx” plugin

    cordova plugin add cordova-plugin-androidx

  • Install “cordova-plugin-androidx-adapter” plugin

    cordova plugin add cordova-plugin-androidx-adapter

  • Add these lines in your gradle.properties :

    android.useAndroidX=true android.enableJetifier=true

After this, make a build: cordova -d build android and check the result

Upvotes: 6

MR Gharibeh
MR Gharibeh

Reputation: 354

solutions is following : make sure the following :

  • Upgrade com.android.tools.build:gradle to v3.2.1 or later.
  • Upgrade compileSdkVersion to 28 or later. . Update your app to use
  • Jetpack (AndroidX); follow the instructions in Migrating to AndroidX.

For Cordova/Ionic project just add the following plugins:

https://github.com/dpa99c/cordova-plugin-androidx https://github.com/dpa99c/cordova-plugin-androidx-adapter Those plugins will fix build error. and everything will work fine :)..

Upvotes: 1

Related Questions