IONIC 4/CLI 5.0.3 - run android error

Hi guys,

I have this error when run in android platform

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

35 actionable tasks: 35 executed
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:
  Program type already present: android.support.v4.os.ResultReceiver$1
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.

* 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 47s
C:\***\apa\platforms\android\gradlew: Command failed with exit code 1 Error output:
Note: C:\***\apa\platforms\android\CordovaLib\src\org\apache\cordova\engine\SystemCookieManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
D8: Program type already present: android.support.v4.os.ResultReceiver$1

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:
  Program type already present: android.support.v4.os.ResultReceiver$1
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.

Ionic info:

Ionic:

   Ionic CLI                     : 5.0.3 
   Ionic Framework               : @ionic/angular 4.5.0
   @angular-devkit/build-angular : 0.12.4
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.2.4
   @ionic/angular-toolkit        : 1.3.0

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 6 other plugins)

Utility:

   cordova-res : 0.3.0
   native-run  : 0.2.6

System:

   Android SDK Tools : 26.1.1
   NodeJS            : v11.10.1 (C:\Program Files\nodejs\node.exe)
   npm               : 6.7.0
   OS                : Windows 10

@NurGuz I’m also getting same error … Did you find any answer…

I have the same error ionic 3. Can someone help?

Try to update IONIC CLI 5 and platforms-tools of android un v 28

1 Like

It solved for me. here is the link: D8: Program type already present

you don’t need it, with update ionic cli 5, native run to 0.2.5 and android-platform v28 is enough

I’m using ionic 3
my ionic info:

cli packages: (/usr/lib/node_modules)

    @ionic/cli-utils  : 1.19.3
    ionic (Ionic CLI) : 3.20.1

global packages:

    cordova (Cordova CLI) : 9.0.0 (cordova-lib@9.0.1) 

local packages:

    @ionic/app-scripts : 3.2.2
    Cordova Platforms  : android 8.0.0
    Ionic Framework    : ionic-angular 3.9.5

System:

    Node : v10.16.0
    npm  : 6.9.0 
    OS   : Linux 4.15

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro