com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

G:\fishbite>ionic info
openssl config failed: error:02001003:system library:fopen:No such process

cli packages: (C:\Users\hp\AppData\Roaming\npm\node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 8.0.0

local packages:

@ionic/app-scripts : 3.1.8
Cordova Platforms  : android 6.4.0
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.1.1
Node              : v8.9.3
npm               : 5.5.1
OS                : Windows 10

Environment Variables:

ANDROID_HOME : C:\Users\hp\AppData\Local\Android\sdk

Misc:

backend : pro

G:\fishbite>ionic cordova build android
openssl config failed: error:02001003:system library:fopen:No such process
Running app-scripts build: --platform android --target cordova
[14:57:12] build dev started …
[14:57:13] clean started …
[14:57:13] clean finished in 160 ms
[14:57:13] copy started …
[14:57:15] deeplinks started …
[14:57:16] deeplinks finished in 686 ms
[14:57:16] transpile started …
[14:57:27] transpile finished in 11.22 s
[14:57:27] preprocess started …
[14:57:27] preprocess finished in 2 ms
[14:57:27] webpack started …
[14:57:29] copy finished in 16.52 s
[14:57:49] webpack finished in 22.14 s
[14:57:49] sass started …
Without from option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to undefined to prevent this warning.
[14:58:00] sass finished in 10.52 s
[14:58:00] postprocess started …
[14:58:00] postprocess finished in 166 ms
[14:58:00] lint started …
[14:58:01] build dev finished in 48.72 s

cordova build android
[14:58:14] tslint: G:/fishbite/src/pages/add-trip/add-trip.ts, line: 2
‘NavController’ is declared but never used.

   L1:  import { Component } from '@angular/core';
   L2:  import { IonicPage, NavController } from 'ionic-angular';
   L3:  import { Camera, CameraOptions } from '@ionic-native/camera';

[14:58:14] tslint: G:/fishbite/src/pages/add-trip/add-trip.ts, line: 3
‘CameraOptions’ is declared but never used.

   L2:  import { IonicPage, NavController } from 'ionic-angular';
   L3:  import { Camera, CameraOptions } from '@ionic-native/camera';

[14:58:14] tslint: G:/fishbite/src/pages/catch-info/catch-info.ts, line: 15
Property ‘navCtrl’ is declared but never used.

  L15:    constructor(private navCtrl: NavController,
  L16:                private navParams: NavParams,

[14:58:14] tslint: G:/fishbite/src/pages/catch-info/catch-info.ts, line: 16
Property ‘navParams’ is declared but never used.

  L15:  constructor(private navCtrl: NavController,
  L16:              private navParams: NavParams,
  L17:              private camera: Camera) {

[14:58:14] tslint: G:/fishbite/src/pages/catch-info/catch-info.ts, line: 3
‘CameraOptions’ is declared but never used.

   L2:  import { IonicPage, NavController, NavParams } from 'ionic-angular';
   L3:  import { Camera, CameraOptions } from '@ionic-native/camera';

[14:58:14] tslint: G:/fishbite/src/pages/add-bait/add-bait.ts, line: 12
Property ‘navCtrl’ is declared but never used.

  L12:    constructor(private navCtrl: NavController,
  L13:                private camera: Camera) {

[14:58:14] tslint: G:/fishbite/src/pages/add-bait/add-bait.ts, line: 3
‘CameraOptions’ is declared but never used.

   L2:  import { IonicPage, NavController } from 'ionic-angular';
   L3:  import { Camera, CameraOptions } from '@ionic-native/camera';

[14:58:14] tslint: G:/fishbite/src/pages/add-moment/add-moment.ts, line: 12
Property ‘navCtrl’ is declared but never used.

  L12:    constructor(private navCtrl: NavController,
  L13:       private viewCtrl: ViewController) {

[14:58:14] tslint: G:/fishbite/src/pages/profile1/profile1.ts, line: 25
Property ‘navParams’ is declared but never used.

  L24:  constructor(private navCtrl: NavController,
  L25:    private navParams: NavParams,
  L26:    private popoverCtrl:PopoverController,

[14:58:14] tslint: G:/fishbite/src/pages/home/home.ts, line: 8
‘CameraOptions’ is declared but never used.

   L7:  import { AddMomentPage } from '../add-moment/add-moment';
   L8:  import { Camera, CameraOptions } from '@ionic-native/camera';
   L9:  import { SocialSharing } from '@ionic-native/social-sharing';

[14:58:14] tslint: G:/fishbite/src/pages/login/login.ts, line: 18
Property ‘navParams’ is declared but never used.

  L17:  constructor(private navCtrl: NavController,
  L18:    private navParams: NavParams,
  L19:    private formBuilder: FormBuilder,

[14:58:14] tslint: G:/fishbite/src/pages/profile/profile.ts, line: 25
Property ‘navParams’ is declared but never used.

  L24:  constructor(private navCtrl: NavController,
  L25:    private navParams: NavParams,
  L26:    private popoverCtrl: PopoverController,

[14:58:14] tslint: G:/fishbite/src/pages/profile/profile.ts, line: 8
‘CameraOptions’ is declared but never used.

   L7:  import { AddMomentPage } from '../add-moment/add-moment';
   L8:  import { Camera, CameraOptions } from '@ionic-native/camera';
   L9:  import { FishIntelPage } from '../fish-intel/fish-intel';

[14:58:14] tslint: G:/fishbite/src/pages/choose-plan-premium-trail/choose-plan-premium-trail.ts, line: 12
Property ‘navParams’ is declared but never used.

  L12:    constructor(private navCtrl: NavController, private navParams: NavParams) {

[14:58:14] tslint: G:/fishbite/src/pages/landing/landing.ts, line: 26
Property ‘navParams’ is declared but never used.

  L25:  constructor(private navCtrl: NavController,
  L26:     private navParams: NavParams,
  L27:     private googlePlus: GooglePlus,

[14:58:14] tslint: G:/fishbite/src/pages/select-language/select-language.ts, line: 16
Property ‘navParams’ is declared but never used.

  L15:  constructor(private navCtrl: NavController,
  L16:     private navParams: NavParams,
  L17:     private languageList: LanguageListProvider) {

[14:58:14] tslint: G:/fishbite/src/pages/forum/forum.ts, line: 18
Property ‘navParams’ is declared but never used.

  L17:  constructor(private navCtrl: NavController,
  L18:    private navParams: NavParams,
  L19:    private popoverCtrl: PopoverController) {

[14:58:14] tslint: G:/fishbite/src/pages/privacy/privacy.ts, line: 15
Property ‘navParams’ is declared but never used.

  L14:  constructor(private navCtrl: NavController,
  L15:     private navParams: NavParams,

ANDROID_HOME=C:\Users\hp\AppData\Local\Android\sdk
L16: private popoverCtrl: PopoverController) {

JAVA_HOME=C:\Program Files\java\jdk1.8.0_131
[14:58:14] tslint: G:/fishbite/src/pages/terms-and-conditions/terms-and-conditions.ts, line: 17
Property ‘navParams’ is declared but never used.

  L16:  constructor(private navCtrl: NavController,
  L17:     private navParams: NavParams,
  L18:     private popoverCtrl: PopoverController) {

[14:58:14] tslint: G:/fishbite/src/pages/help-and-support/help-and-support.ts, line: 18
Property ‘navParams’ is declared but never used.

  L17:  constructor(private navCtrl: NavController,
  L18:     private navParams: NavParams,
  L19:     private popoverCtrl: PopoverController) {

[14:58:14] tslint: G:/fishbite/src/pages/loyality-competition/loyality-competition.ts, line: 19
Property ‘navParams’ is declared but never used.

  L18:  private navCtrl: NavController,
  L19:  private navParams: NavParams,
  L20:  private popoverCtrl: PopoverController,) {

[14:58:14] tslint: G:/fishbite/src/pages/signup/signup.ts, line: 19
Property ‘navParams’ is declared but never used.

  L19:    constructor(private navCtrl: NavController, private navParams: NavParams) {

[14:58:14] tslint: G:/fishbite/src/pages/join-local-fish-communi/join-local-fish-communi.ts, line: 13
Property ‘navParams’ is declared but never used.

  L13:    constructor(private navCtrl: NavController, private navParams: NavParams) {

[14:58:14] lint finished in 14.23 s
Subproject Path: CordovaLib
Configuration ‘compile’ in project ‘:’ is deprecated. Use ‘implementation’ instead.

The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
at build_3hvfs0g0dbi4qz5htstxl0zvj.run(G:\fishbite\platforms\android\build.gradle:143)
publishNonDefault is deprecated and has no effect anymore. All variants are now published.

:preBuild
UP-TO-DATE
:CordovaLib:preBuild
UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:checkDebugManifest

:CordovaLib:processDebugManifest

:preDebugBuild

:CordovaLib:compileDebugAidl

:compileDebugAidl

:CordovaLib:packageDebugRenderscript NO-SOURCE
:compileDebugRenderscript

:checkDebugManifest
:generateDebugBuildConfig

:prepareLintJar

UP-TO-DATE
:generateDebugResValues

:generateDebugResources

:CordovaLib:compileDebugRenderscript

:CordovaLib:generateDebugResValues

:CordovaLib:generateDebugResources

:CordovaLib:packageDebugResources

:mergeDebugResources

:createDebugCompatibleScreenManifests

:processDebugManifest

:splitsDiscoveryTaskDebug

:CordovaLib:platformAttrExtractor

:CordovaLib:generateDebugBuildConfig

:CordovaLib:prepareLintJar UP-TO-DATE
:CordovaLib:javaPreCompileDebug

:CordovaLib:processDebugJavaRes

NO-SOURCE
:compileDebugNdk

NO-SOURCE
:mergeDebugShaders

:compileDebugShaders

:generateDebugAssets
:CordovaLib:mergeDebugShaders

:CordovaLib:compileDebugShaders

:CordovaLib:generateDebugAssets
:CordovaLib:mergeDebugAssets

:mergeDebugAssets

:mergeDebugJniLibFolders

:CordovaLib:compileDebugNdk NO-SOURCE
:CordovaLib:mergeDebugJniLibFolders

:CordovaLib:transformNativeLibsWithMergeJniLibsForDebug

:CordovaLib:transformNativeLibsWithIntermediateJniLibsForDebug

:processDebugJavaRes
NO-SOURCE

:validateSigningDebug

:CordovaLib:processDebugResources

:processDebugResources

:generateDebugSources
:CordovaLib:generateDebugSources
:CordovaLib:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

:CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug

:javaPreCompileDebug

:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

:compileDebugSources
:transformClassesWithDexBuilderForDebug

:transformDexArchiveWithExternalLibsDexMergerForDebug

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:
    FAILED
    40 actionable tasks: 38 executed, 2 up-to-date
    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 3m 35s
(node:2856) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output:
Note: Some input files use or override 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.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

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 3m 35s
Picked up _JAVA_OPTIONS: -Xmx512M
(node:2856) [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.

G:\fishbite>cordova requirements

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-26,android-25,android-24,Google Inc.:Google APIs:24,android-23,android-22,android-21,android-19,android-18,android-17,android-16,android-15,android-14
Gradle: installed C:\Program Files\Android\Android Studio\gradle\gradle-4.4\bin\gradle

Your Cordova tooling seems to be out of date, which might be causing all kinds of problems.
You can read about how to figure out the current Cordova versions and how to update CLI, platforms and plugins here: https://ionic.zone/cordova/update

G:\fishbite>cordova plugin list
openssl config failed: error:02001003:system library:fopen:No such process
cordova-plugin-camera 4.0.2 “Camera”
cordova-plugin-device 2.0.1 “Device”
cordova-plugin-facebook4 1.9.1 “Facebook Connect”
cordova-plugin-googlemaps 2.2.5 “cordova-plugin-googlemaps”
cordova-plugin-googleplus 5.2.1 “Google SignIn”
cordova-plugin-inappbrowser 2.0.2 “InAppBrowser”
cordova-plugin-ionic-keyboard 2.0.5 “cordova-plugin-ionic-keyboard”
cordova-plugin-ionic-webview 1.1.16 “cordova-plugin-ionic-webview”
cordova-plugin-nativeaudio 3.0.9 “Cordova Native Audio”
cordova-plugin-splashscreen 5.0.2 “Splashscreen”
cordova-plugin-whitelist 1.3.3 “Whitelist”
cordova-plugin-x-socialsharing 5.2.1 “SocialSharing”
es6-promise-plugin 4.1.0 “Promise”

G:\fishbite>

G:\fishbite>npm outdated
openssl config failed: error:02001003:system library:fopen:No such process
openssl config failed: error:02001003:system library:fopen:No such process
Package                            Current  Wanted  Latest  Location
@angular/common                      5.0.3   5.0.3   5.2.9  fishbite
@angular/compiler                    5.0.3   5.0.3   5.2.9  fishbite
@angular/compiler-cli                5.0.3   5.0.3   5.2.9  fishbite
@angular/core                        5.0.3   5.0.3   5.2.9  fishbite
@angular/forms                       5.0.3   5.0.3   5.2.9  fishbite
@angular/http                        5.0.3   5.0.3   5.2.9  fishbite
@angular/platform-browser            5.0.3   5.0.3   5.2.9  fishbite
@angular/platform-browser-dynamic    5.0.3   5.0.3   5.2.9  fishbite
@ionic-native/camera                 4.5.3   4.6.0   4.6.0  fishbite
@ionic-native/core                   4.4.0   4.4.0   4.6.0  fishbite
@ionic-native/facebook               4.5.3   4.6.0   4.6.0  fishbite
@ionic-native/google-maps            4.5.3   4.6.1   4.6.1  fishbite
@ionic-native/google-plus            4.5.3   4.6.0   4.6.0  fishbite
@ionic-native/in-app-browser         4.5.3   4.6.0   4.6.0  fishbite
@ionic-native/native-audio           4.5.3   4.6.0   4.6.0  fishbite
@ionic-native/social-sharing         4.5.3   4.6.0   4.6.0  fishbite
@ionic-native/splash-screen          4.4.0   4.4.0   4.6.0  fishbite
@ionic-native/status-bar             4.4.0   4.4.0   4.6.0  fishbite
@ionic/pro                          1.0.17  1.0.17  1.0.20  fishbite
cordova-android                      6.4.0   6.4.0   7.1.0  fishbite
cordova-plugin-googlemaps            2.2.5   2.2.9   2.2.9  fishbite
cordova-plugin-googleplus            5.2.1   5.2.2   5.2.2  fishbite
cordova-plugin-x-socialsharing       5.2.1   5.3.2   5.3.2  fishbite
rxjs                                 5.5.2   5.5.2   5.5.8  fishbite
typescript                           2.4.2   2.4.2   2.8.1  fishbite
zone.js

* List item

It seems the dex version is causing the error.
You can build but by removing the camera plugin from your project. I know that’s not a solution but you can do that for checking purpose.
I think the camera plugin is creating some issue.
(remember to remove the plugin from the folder of your project also)
the last option would be removing both the platforms and re-adding them.

I removed camera plugin and also re-adding platform but the problem is same.


See red color line above warning!!

Did you delete the platform and plugin folder???

no, I have not deleted

if you have the backup of your project then delete the folder platform and plugin then try re-adding the platforms in CLI… that should work.

1 Like

thanks! yes, its working

You’re welcome!!
If it happens again in future with other project then it’s better to start a new project and copy the pages, assets, app folder of the old project and replace it on the new project.

2 Likes

wow Thank you
Finally Solved the problem.
God bless you!