D8: Program type already present

i’ have this error when try build android on ionic v-3.

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

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.

  Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver

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


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

BUILD FAILED in 15s
37 actionable tasks: 5 executed, 32 up-to-date
/*/*/*/m/*/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.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
  Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver

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

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

BUILD FAILED in 15s
[ERROR] An error occurred while running cordova run android (exit code 1).

can someone help please…

Same issue here. I’m updating Gradle and Android SDK…

Could help, it worked for me : https://github.com/arnesson/cordova-plugin-firebase/issues/1083#issuecomment-503650114

1 Like

@JerryBels Exactly, the issue is linked to last updates from Android support library to AndroidX

@dessteyu I fixed it following this post https://github.com/arnesson/cordova-plugin-firebase/issues/1081#issuecomment-503135862

0 / Remove your android platform

1 / Remove all plugins related to support / gradle / firebase versions control

2 / Add the AndroidX plugins from @dpa99c :

# add plugin to enable AndroidX in the project
cordova plugin add cordova-plugin-androidx

# add plugin to patch existing plugin source that uses the Android Support Library to use AndroidX
cordova plugin add cordova-plugin-androidx-adapter

3 / Add your android platform

1 Like

Thank you @MathieuNa, it’s working well now.