Phonegap-plugin-barcodescanner: Build failed with ionic cordova android 6.4.0 and phonegap-plugin-barcodescanner 7.1.0

Created on 7 Apr 2018  路  5Comments  路  Source: phonegap/phonegap-plugin-barcodescanner

Expected Behaviour

Build should succeed.

Actual Behaviour

BUILD FAILED in 13s
42 actionable tasks: 42 executed
Error: /Users/andrea/Siti/xxxxxx.it/app/platforms/android/gradlew: 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.
Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/EditorInfoCompat;
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/EditorInfoCompat;

com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/EditorInfoCompat;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1689)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':transformDexArchiveWithDexMergerForDebug'.
    > com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Landroid/support/v13/view/inputmethod/EditorInfoCompat;

Reproduce Scenario (including but not limited to)

ionic cordova plugin ls

cordova plugin ls
branch-cordova-sdk 2.6.24 "branch-cordova-sdk"
cordova-launch-review 3.1.0 "Launch Review"
cordova-plugin-advanced-http 1.11.1 "Advanced HTTP plugin"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-device 2.0.1 "Device"
cordova-plugin-facebook4 1.9.1 "Facebook Connect"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-googleplus 5.2.1 "Google SignIn"
cordova-plugin-inappbrowser 2.0.2 "InAppBrowser"
cordova-plugin-ionic 4.1.0 "IonicCordova"
cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview"
cordova-plugin-market 1.2.0 "Market"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.1 "StatusBar"
cordova-plugin-swift-support 3.1.1 "SwiftSupport"
cordova-plugin-whitelist 1.3.3 "Whitelist"
phonegap-plugin-barcodescanner 7.1.0 "BarcodeScanner"
phonegap-plugin-push 2.1.3 "PushPlugin"

Steps to Reproduce

ionic cordova build android

Platform and Version

ionic info

cli packages: (/usr/local/lib/node_modules)

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

global packages:

cordova (Cordova CLI) : 7.1.0

local packages:

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

System:

Android SDK Tools : 26.1.1
ios-deploy        : 1.9.2 
Node              : v9.3.0
npm               : 5.6.0 
OS                : macOS High Sierra
Xcode             : Xcode 9.3 Build version 9E145

Environment Variables:

ANDROID_HOME : /Users/andrea/Library/Android/sdk

Misc:

backend : pro

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

Cordova CLI version and cordova platform version

cordova --version
cordova platforms

Plugin version

cordova plugin version | grep phonegap-plugin-barcodescanner

Sample Code that illustrates the problem

Logs taken while reproducing problem

All 5 comments

@andreandev I had got the same error. For me it was due to phonegap-plugin-plus which was using com.android.support:support-v13:26.+. I forked the repo and changed it. Now it is working fine. You can use this corrected repo https://github.com/pdmshrestha/phonegap-plugin-barcodescanner and test it.

cordova plugin add https://github.com/pdmshrestha/phonegap-plugin-barcodescanner

Thank you so much @pdmshrestha!
This problem was driving me crazy.

This plugin allows to configure the android support version with a variable, you can do it on plugin install or by adding it to the config.xml like this:

<plugin name="phonegap-plugin-barcodescanner">
   <variable name="ANDROID_SUPPORT_V4_VERSION" value="26+" />
</plugin>

27.+ is just the default value.

Same thing for push plugin (but for ANDROID_SUPPORT_V13_VERSION) . Make sure all your plugins are using the same version for Android support libraries

Thanks @jcesarmobile, this is a helpful feature. But I don't see it anywhere in the documentation.
Maybe a pitfalls section should be added to explain how to deal with the DexException problem.

This thread has been automatically locked.

Was this page helpful?
0 / 5 - 0 ratings