Build failed with cordova android 7.0.0 and phonegap-plugin-barcodescanner 7.0.2
Started with the Tutorial project for Ionic v1. Loaded the Facebook plugin (https://github.com/jeduan/cordova-plugin-facebook4) and Android compilation is fine. Added 7.0.2 Barcode scanner and now getting Dex compile errors of the form:
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
I have had trouble with older versions of Ionic CLI, Facebook and BarCodeScanner in conflict, so I am suspicious it is related to that but am not sure nor know how to confirm.
Build should succeed.
Build fails with error
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
ionic start BarCodeTest tutorial
cd BarCodeTest
ionic cordova platform add android
ionic cordova build android
cordova plugin add cordova-plugin-facebook4 --save --variable APP_ID="<redacted>" --variable APP_NAME="bookship"
ionic cordova build android (this works)
cordova plugin add phonegap-plugin-barcodescanner
npm install --save @ionic-native/barcode-scanner
ionic cordova build android (this fails)
Marks-Air-2:BarCodeTest markwatkins$ ionic info
cli packages: (/Users/markwatkins/.nvm/versions/node/v8.9.4/lib/node_modules)
@ionic/cli-utils : 1.19.1
ionic (Ionic CLI) : 3.19.1
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
@ionic/app-scripts : 3.1.8
Cordova Platforms : android 7.0.0
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
ios-deploy : 1.9.2
Node : v8.9.4
npm : 5.6.0
OS : macOS High Sierra
Xcode : Xcode 9.2 Build version 9C40b
Environment Variables:
ANDROID_HOME : /Users/markwatkins/Library/Android/sdk
Misc:
backend : pro
Marks-Air-2:BarCodeTest markwatkins$ cordova plugin list
cordova-plugin-device 2.0.1 "Device"
cordova-plugin-facebook4 1.9.1 "Facebook Connect"
cordova-plugin-ionic-keyboard 2.0.5 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-whitelist 1.3.3 "Whitelist"
phonegap-plugin-barcodescanner 7.0.2 "BarcodeScanner"
Marks-Air-2:BarCodeTest markwatkins$
Marks-Air-2:BarCodeTest markwatkins$ cordova --version
8.0.0
Marks-Air-2:BarCodeTest markwatkins$ cordova platforms
Installed platforms:
android 7.0.0
Available platforms:
browser ~5.0.1
ios ~4.5.4
osx ~4.0.1
windows ~5.0.0
www ^3.12.0
cordova plugin version | grep phonegap-plugin-barcodescanner
Marks-Air-2:BarCodeTest $ cordova plugin version | grep phonegap-plugin-barcodescanner
phonegap-plugin-barcodescanner 7.0.2 "BarcodeScanner"
complete log below
Marks-Air-2:Sites mw$ more foo.bash
ionic start BarCodeTest tutorial
cd BarCodeTest
ionic cordova platform add android
ionic cordova build android
cordova plugin add cordova-plugin-facebook4 --save --variable APP_ID="
ionic cordova build android
cordova plugin add phonegap-plugin-barcodescanner
npm install --save @ionic-native/barcode-scanner
ionic cordova build android
Marks-Air-2:Sites mw$ ./foo.bash
✔ Creating directory ./BarCodeTest - done!
✔ Downloading and extracting tutorial starter - done!
? Would you like to integrate your new app with Cordova to target native iOS and Android? Yes
✔ Personalizing ionic.config.json and package.json - done!
ionic integrations enable cordova --quiet
✔ Downloading integration cordova - done!
✔ Copying integrations files to project - done!
[OK] Added cordova integration!
Installing dependencies may take several minutes.
✨ IONIC DEVAPP ✨
Speed up development with the Ionic DevApp, our fast, on-device testing mobile app
🚀 LiveReload for instant style and JS updates
️--> Install DevApp: https://bit.ly/ionic-dev-app <--
npm i
✔ Running command - done!
git init
🔥 IONIC PRO 🔥
Supercharge your Ionic development with the Ionic Pro SDK
Learn more about Ionic Pro: https://ionicframework.com/products
? Install the free Ionic Pro SDK and connect your app? No
git add -A
git commit -m "Initial commit" --no-gpg-sign
Next Steps:
✔ Creating ./www directory for you - done!
cordova platform add android --save
Using cordova-fetch for cordova-android@~7.0.0
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: io.ionic.starter
Name: BarCodeTest
Activity: MainActivity
Android target: android-26
Subproject Path: CordovaLib
Subproject Path: app
Android project created with [email protected]
Android Studio project detected
Android Studio project detected
Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
Installing "cordova-plugin-whitelist" for android
This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.
Adding cordova-plugin-whitelist to package.json
Saved plugin info for "cordova-plugin-whitelist" to config.xml
Discovered plugin "cordova-plugin-device" in config.xml. Adding it to the project
Installing "cordova-plugin-device" for android
Adding cordova-plugin-device to package.json
Saved plugin info for "cordova-plugin-device" to config.xml
Discovered plugin "cordova-plugin-splashscreen" in config.xml. Adding it to the project
Installing "cordova-plugin-splashscreen" for android
Adding cordova-plugin-splashscreen to package.json
Saved plugin info for "cordova-plugin-splashscreen" to config.xml
Discovered plugin "cordova-plugin-ionic-webview" in config.xml. Adding it to the project
Installing "cordova-plugin-ionic-webview" for android
Adding cordova-plugin-ionic-webview to package.json
Saved plugin info for "cordova-plugin-ionic-webview" to config.xml
Discovered plugin "cordova-plugin-ionic-keyboard" in config.xml. Adding it to the project
Installing "cordova-plugin-ionic-keyboard" for android
Adding cordova-plugin-ionic-keyboard to package.json
Saved plugin info for "cordova-plugin-ionic-keyboard" to config.xml
--save flag or autosave detected
Saving android@~7.0.0 into config.xml file ...
ionic cordova resources android --force
✔ Collecting resource configuration and source images - done!
✔ Filtering out image resources that do not need regeneration - done!
✔ Uploading source images to prepare for transformations - done!
✔ Generating platform resources: 18 / 18 complete - done!
✔ Modifying config.xml to add new image resources - done!
Running app-scripts build: --platform android --target cordova
[16:37:02] build dev started ...
[16:37:02] clean started ...
[16:37:02] clean finished in 3 ms
[16:37:02] copy started ...
[16:37:02] deeplinks started ...
[16:37:02] deeplinks finished in 48 ms
[16:37:02] transpile started ...
[16:37:08] transpile finished in 6.08 s
[16:37:08] preprocess started ...
[16:37:08] preprocess finished in less than 1 ms
[16:37:08] webpack started ...
[16:37:08] copy finished in 6.35 s
[16:37:19] webpack finished in 10.59 s
[16:37:19] sass started ...
Withoutfromoption PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or toundefinedto prevent this warning.
[16:37:20] sass finished in 1.65 s
[16:37:20] postprocess started ...
[16:37:20] postprocess finished in 11 ms
[16:37:20] lint started ...
[16:37:20] build dev finished in 18.55 s
cordova build android
Android Studio project detected
ANDROID_HOME=/Users/mw/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
studio
:wrapper
BUILD SUCCESSFUL in 2s
1 actionable task: 1 executed
Subproject Path: CordovaLib
Subproject Path: app
[16:37:27] lint finished in 6.39 s
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
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_1jyq10tezdufy71arrq2cemip.run(/Users/mw/Sites/BarCodeTest/platforms/android/app/build.gradle:143)
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:compileDebugAidl
:CordovaLib:compileDebugRenderscript
:CordovaLib:checkDebugManifest
:CordovaLib:generateDebugBuildConfig
:CordovaLib:prepareLintJar
:CordovaLib:generateDebugResValues
:CordovaLib:generateDebugResources
:CordovaLib:packageDebugResources
:CordovaLib:platformAttrExtractor
:CordovaLib:processDebugManifest
:CordovaLib:javaPreCompileDebug
:CordovaLib:processDebugJavaRes NO-SOURCE
:app:preBuild UP-TO-DATE
:app:preDebugBuild
:CordovaLib:packageDebugRenderscript
NO-SOURCE
:app:compileDebugRenderscript
:app:checkDebugManifest
:app:generateDebugBuildConfig
:app:prepareLintJar
:app:generateDebugResValues
:app:generateDebugResources
:app:mergeDebugResources
:app:createDebugCompatibleScreenManifests
:app:splitsDiscoveryTaskDebug
:app:compileDebugNdk
NO-SOURCE
:CordovaLib:mergeDebugShaders
:CordovaLib:compileDebugShaders
:CordovaLib:generateDebugAssets
:CordovaLib:mergeDebugAssets
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:extractTryWithResourcesSupportJarDebug
:CordovaLib:compileDebugNdk NO-SOURCE
:CordovaLib:mergeDebugJniLibFolders
:CordovaLib:transformNativeLibsWithMergeJniLibsForDebug
:CordovaLib:transformNativeLibsWithIntermediateJniLibsForDebug
:app:processDebugJavaRes NO-SOURCE
:app:validateSigningDebug
:CordovaLib:processDebugResources
:CordovaLib:generateDebugSources
:CordovaLib:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug
:app:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:app:compileDebugSources
:app:transformClassesWithStackFramesFixerForDebug
:app:transformClassesWithDesugarForDebug
:app:transformClassesWithDexBuilderForDebug
:app:transformDexArchiveWithExternalLibsDexMergerForDebug
:app:transformDexArchiveWithDexMergerForDebug
:app:transformNativeLibsWithMergeJniLibsForDebug
:app:transformResourcesWithMergeJavaResForDebug
:app:assembleDebug
:app:cdvBuildDebug
BUILD SUCCESSFUL in 10s
47 actionable tasks: 47 executed
Built the following apk(s):
/Users/mw/Sites/BarCodeTest/platforms/android/app/build/outputs/apk/debug/app-debug.apk
Installing "cordova-plugin-facebook4" for android
Android Studio project detected
Subproject Path: CordovaLib
Subproject Path: app
Adding cordova-plugin-facebook4 to package.json
Saved plugin info for "cordova-plugin-facebook4" to config.xml
Running app-scripts build: --platform android --target cordova
[16:38:01] build dev started ...
[16:38:01] clean started ...
[16:38:01] clean finished in 9 ms
[16:38:01] copy started ...
[16:38:02] deeplinks started ...
[16:38:02] deeplinks finished in 34 ms
[16:38:02] transpile started ...
[16:38:08] transpile finished in 6.18 s
[16:38:08] preprocess started ...
[16:38:08] preprocess finished in 1 ms
[16:38:08] webpack started ...
[16:38:08] copy finished in 6.41 s
[16:38:16] webpack finished in 8.60 s
[16:38:16] 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.
[16:38:18] sass finished in 1.37 s
[16:38:18] postprocess started ...
[16:38:18] postprocess finished in 7 ms
[16:38:18] lint started ...
[16:38:18] build dev finished in 16.44 s
cordova build android
Android Studio project detected
ANDROID_HOME=/Users/mw/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
studio
Subproject Path: CordovaLib
Subproject Path: app
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
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_1jyq10tezdufy71arrq2cemip.run(/Users/mw/Sites/BarCodeTest/platforms/android/app/build.gradle:143)
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
:CordovaLib:preBuild
UP-TO-DATE
UP-TO-DATE
UP-TO-DATE
:CordovaLib:compileDebugRenderscript
UP-TO-DATE
:CordovaLib:checkDebugManifest
UP-TO-DATE
:CordovaLib:generateDebugBuildConfig
UP-TO-DATE
UP-TO-DATE
:CordovaLib:generateDebugResValues
UP-TO-DATE
:CordovaLib:generateDebugResources
UP-TO-DATE
:CordovaLib:packageDebugResources
UP-TO-DATE
:CordovaLib:platformAttrExtractor UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:CordovaLib:processDebugResources
UP-TO-DATE
:CordovaLib:generateDebugSources
UP-TO-DATE
:CordovaLib:javaPreCompileDebug
UP-TO-DATE
:CordovaLib:compileDebugJavaWithJavac
UP-TO-DATE
:CordovaLib:processDebugJavaRes
NO-SOURCE
:CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug
UP-TO-DATE
UP-TO-DATE
:app:preDebugBuild
:CordovaLib:packageDebugRenderscript NO-SOURCE
:app:compileDebugRenderscript
UP-TO-DATE
:app:checkDebugManifest
UP-TO-DATE
:app:generateDebugBuildConfig
UP-TO-DATE
:app:prepareLintJar
UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources
[16:38:23] lint finished in 5.46 s
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources
:app:generateDebugSources
:app:javaPreCompileDebug
:app:compileDebugJavaWithJavac
Note: /Users/mw/Sites/BarCodeTest/platforms/android/app/src/main/java/org/apache/cordova/facebook/ConnectPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:app:compileDebugNdk NO-SOURCE
:app:compileDebugSources
:CordovaLib:mergeDebugShaders UP-TO-DATE
:CordovaLib:compileDebugShaders UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets
UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:extractTryWithResourcesSupportJarDebug UP-TO-DATE
:app:transformClassesWithStackFramesFixerForDebug
:app:transformClassesWithDesugarForDebug
:app:transformClassesWithDexBuilderForDebug
:app:transformDexArchiveWithExternalLibsDexMergerForDebug
:app:transformDexArchiveWithDexMergerForDebug
:CordovaLib:compileDebugNdk NO-SOURCE
:CordovaLib:mergeDebugJniLibFolders UP-TO-DATE
:CordovaLib:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
:CordovaLib:transformNativeLibsWithIntermediateJniLibsForDebug UP-TO-DATE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNativeLibsWithMergeJniLibsForDebug
:app:processDebugJavaRes
NO-SOURCE
:app:transformResourcesWithMergeJavaResForDebug
:app:validateSigningDebug
:app:packageDebug
:app:assembleDebug
:app:cdvBuildDebug
BUILD SUCCESSFUL in 22s
47 actionable tasks: 17 executed, 30 up-to-date
Built the following apk(s):
/Users/mw/Sites/BarCodeTest/platforms/android/app/build/outputs/apk/debug/app-debug.apk
Installing "phonegap-plugin-barcodescanner" for android
Android Studio project detected
Subproject Path: CordovaLib
Subproject Path: app
Adding phonegap-plugin-barcodescanner to package.json
Saved plugin info for "phonegap-plugin-barcodescanner" to config.xml
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.cordova build android
Android Studio project detected
ANDROID_HOME=/Users/mw/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
studio
Subproject Path: CordovaLib
Subproject Path: app
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
Configuration 'compile' in project ':app' 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_1jyq10tezdufy71arrq2cemip.run(/Users/mw/Sites/BarCodeTest/platforms/android/app/build.gradle:144)
:CordovaLib:preBuild
UP-TO-DATE
:CordovaLib:preDebugBuild
UP-TO-DATE
:CordovaLib:compileDebugAidl
UP-TO-DATE
:CordovaLib:compileDebugRenderscript
UP-TO-DATE
:CordovaLib:checkDebugManifest
UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:prepareLintJar UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:platformAttrExtractor UP-TO-DATE
:CordovaLib:processDebugManifest
UP-TO-DATE
:CordovaLib:processDebugResources
UP-TO-DATE
:CordovaLib:generateDebugSources
UP-TO-DATE
:CordovaLib:javaPreCompileDebug
UP-TO-DATE
:CordovaLib:compileDebugJavaWithJavac
UP-TO-DATE
:CordovaLib:processDebugJavaRes
NO-SOURCE
:CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug UP-TO-DATE
:app:preBuild UP-TO-DATE
:app:preDebugBuild
UP-TO-DATE
:CordovaLib:packageDebugRenderscript
NO-SOURCE
:app:compileDebugRenderscript
UP-TO-DATE
:app:checkDebugManifest
UP-TO-DATE
:app:generateDebugBuildConfig
UP-TO-DATE
:app:prepareLintJar
UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
UP-TO-DATE
:app:mergeDebugResources
[16:39:31] lint finished in 6.39 s
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug
UP-TO-DATE
:app:processDebugResources
:app:generateDebugSources
:app:javaPreCompileDebug
:app:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:app:compileDebugNdk NO-SOURCE
:app:compileDebugSources
:CordovaLib:mergeDebugShaders UP-TO-DATE
:CordovaLib:compileDebugShaders UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders
UP-TO-DATE
:app:generateDebugAssets
UP-TO-DATE
:app:extractTryWithResourcesSupportJarDebug UP-TO-DATE
:app:transformClassesWithStackFramesFixerForDebug
:app:transformClassesWithDesugarForDebug
:app:transformClassesWithDexBuilderForDebug
:app:transformDexArchiveWithExternalLibsDexMergerForDebug
FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app: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 14s
38 actionable tasks: 11 executed, 27 up-to-date
(node:92159) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: /Users/mw/Sites/BarCodeTest/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.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app: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 14s
(node:92159) [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.
Marks-Air-2:Sites mw$
Marks-Air-2:BarCodeTest mw$ ionic info
cli packages: (/Users/mw/.nvm/versions/node/v8.9.4/lib/node_modules)
@ionic/cli-utils : 1.19.1
ionic (Ionic CLI) : 3.19.1
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
@ionic/app-scripts : 3.1.8
Cordova Platforms : android 7.0.0
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
ios-deploy : 1.9.2
Node : v8.9.4
npm : 5.6.0
OS : macOS High Sierra
Xcode : Xcode 9.2 Build version 9C40b
Environment Variables:
ANDROID_HOME : /Users/mw/Library/Android/sdk
Misc:
backend : pro
Marks-Air-2:BarCodeTest mw$ cordova plugin list
cordova-plugin-device 2.0.1 "Device"
cordova-plugin-facebook4 1.9.1 "Facebook Connect"
cordova-plugin-ionic-keyboard 2.0.5 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-whitelist 1.3.3 "Whitelist"
phonegap-plugin-barcodescanner 7.0.2 "BarcodeScanner"
Marks-Air-2:BarCodeTest mw$
I get essentially the same error when trying cordova 6.4.0 as well, e.g. start a new project with the same steps except
ionic cordova platform add [email protected]
get same error.
Any suggestions greatly appreciated! A few other issues may be duplicates, I have tried the suggested workarounds there as well and none seem to be working for me (e.g. https://github.com/phonegap/phonegap-plugin-barcodescanner/issues/535 and https://github.com/phonegap/phonegap-plugin-barcodescanner/issues/595
btw I faced a similar issue with older versions about 8 months ago - the attached discussion on this issue (https://github.com/jeduan/cordova-plugin-facebook4/issues/507) indicates the problem is with barcodescanner and not facebook plugin. I'm not enough of an Android person to say but lots of investigative detail there...
I have the same issue. When both barcode and facebook4 run in isolation, build fails. When used separately without the other, build succeeds. I tried many versions of facebook4 plugin and found, on cli-8.0.0 with facebook4 version 1.7.4 and with the latest on barcode, build succeeds.
Thanks wizajay. That worked fine. I just removed the current version:
ionic cordova plugin remove cordova-plugin-facebook4
and put on the 1.7.4 version
ionic cordova plugin add [email protected]
and it all compiled fine
@viking2917 the facebook plugin includes the facebook sdk which includes a library that is used by many other Android SDK's. This is what is causing the _Unable to merge dex_ error. I don't currently have a work around other than using an older version of the Facebook plugin that uses an older version of the Facebook SDK.
Thanks @macdonst; appreciate you looking into it. Like others I am using the @1.7.4 version with success for the moment.
Oy, thats not good. facebook4 is up to 1.9.1 - so it will be several revs behind.
Have you tried using cordova-android-support-gradle-release to align your SDK's?
@rolinger thanks for the suggestion; looks promising, except that I use the push plugin which the gradle-release plugin suggests will cause it problems. So I have not actually tried it.
Hello,
in my case, barcodescanner plugin has started blocking android project compilation suddenly. I used it for days without any problem and in a certain point it started hanging on transformDexArchiveWithExternalLibsDexMergerForDebug.
I haven't installed anything, no other plugins, nor the facebook plugin.
EDIT: in my case, I resolved removing this string:
compile 'com.android.support:support-v4:+'
from the file:
(your_project)-barcodescanner.gradle
EDIT2: during my tests, I discoverd that my problem was caused by a sort of incompatibility with phonegap-plugin-push.
I had the same experience as @studiostart, this started breaking without any apparent changes on my part and my previous workaround of using 1.7.4 of the Facebook plugin does not help. I took the same steps as @studiostart, more specifically I deleted
compile 'com.android.support:support-v4:+'
from the file
<projectroot>/plugins/phonegap-plugin-barcodescanner/src/android/barcodescanner.gradle
and then did
ionic cordova platform remove android
ionic cordova platform add android
And that seemed to fix the issue. I am too much of an Android n00b to know whether this causing some other problem I haven't though of, or whether this would make an appropriate pull request....
@macdonst do you think this is a hack or a general solution?
@viking2917 it worked for me, thanks!
@viking2917 's solution allowed it to build, but the plugin failed to run in my app.
Solution: rather than remove compile 'com.android.support:support-v4:+', change it to compile 'com.android.support:support-v4:25.3.1'
My story:
initial build fail terminal log:
:processDebugResources/Users/jfhome/.gradle/caches/transforms-1/files-1.1/support-compat-28.0.0-alpha1.aar/0d888cdbfc407d3d5333be4b445453bd/res/values/values.xml:20:5-70: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/jfhome/.gradle/caches/transforms-1/files-1.1/support-compat-28.0.0-alpha1.aar/0d888cdbfc407d3d5333be4b445453bd/res/values/values.xml:20:5-70: AAPT: error: resource android:attr/ttcIndex not found.
/Users/jfhome/devProjects/ircscanner/platforms/android/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:141: error: resource android:attr/fontVariationSettings not found.
/Users/jfhome/devProjects/ircscanner/platforms/android/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:141: error: resource android:attr/ttcIndex not found.
error: failed linking references.
Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
plugins:
cordova-plugin-console 1.0.5 "Console"
cordova-plugin-device 1.1.6 "Device"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.4.1 "StatusBar"
cordova-plugin-whitelist 1.3.1 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-plugin-barcodescanner 7.0.2 "BarcodeScanner"
Ionic CLI 3.10.1
Cordova 8.0.0
Android Platform version: 7.0.0
I found a note on Android's Documentation:
Note: Prior to Support Library revision 24.2.0, there was a single v4 support library. That library was divided into multiple modules to improve efficiency. For backwards compatibility, if you list support-v4 in your Gradle script, your APK will include all of the v4 modules. However, to reduce APK size, we recommend that you just list the specific modules your app needs.
ref: https://developer.android.com/topic/libraries/support-library/packages.html
Perhaps specifying which v4 modules this plugin depends on will be a better fix then simply removing v4 completely? Ah well lets give it a try.
I removed compile 'com.android.support:support-v4:+', but plugin failed to run when I started the barcode scanner in my app. Got this error:
E/AndroidRuntime( 6096): FATAL EXCEPTION: main
E/AndroidRuntime( 6096): Process: com.sjs.ircsmartscan, PID: 6096
E/AndroidRuntime( 6096): java.lang.NoClassDefFoundError: android.support.v4.content.LocalBroadcastManager
Pretty clear the plugin depends on some v4 modules. I tried adding localbroadcastmanager as a dependency with no luck. Searching around for failed attempts to add this particular dependency lead me to a suggestion to add: com.android.support:support-v4:25.3.1 as a dependency instead. That worked! Now the app builds and the barcode scanner works!
@jfbloom22 that works for me too :)
@jfbloom22 thanks it's working wow......
@jfbloom22 that works for me too :)
In my case
Cordova 8.0.0
Cordova Android Platform version: 7.1.0
@jfbloom22 excelente solución, muchas gracias
@jfbloom22 Nice find. Thanks.
For PGB, I forked this plugin repo and edited the gradle file as @jfbloom22 had mentioned and using it instead. But still FB plugin works only with version 1.7.4
<plugin spec="https://github.com/slickalpha/phonegap-plugin-barcodescanner.git" source="git">
<param name="CAMERA_USAGE_DESCRIPTION" value="To scan barcodes" />
</plugin>
<plugin name="cordova-plugin-facebook4" spec="1.7.4" source="npm">
<param name="APP_ID" value="your_app_id" />
<param name="APP_NAME" value="your_app_name" />
</plugin>
Hope to see a permanent solution to this issue.
Latest version 7.0.3 with commit #621 fix this problem
When I try to use this fixed version I get this error:
FAILURE: Build failed with an exception.
Where:
Build file '/xxx/build/mobile/platforms/android/build.gradle' line: 259
What went wrong:
A problem occurred evaluating root project 'android'.
Could not get unknown property 'ANDROID_SUPPORT_V4_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
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
Any ideas?
Fix for the Facebook plugin was to force the Facebook SDK to version 4.25.0.
cordova plugin add cordova-plugin-platform-replace
Then add to your config.xml
<platform name="android">
<replace-string file="project.properties" find="regex:com\.facebook\.android\:facebook-android-sdk\:[\+0-9\.]+" replace="com.facebook.android:facebook-android-sdk:4.25.0" />
</platform>
Finally run cordova prepare android
Works with the latest 1.9.1 version of cordova-facebook-plugin4
FAILED
38 actionable tasks: 1 executed, 37 up-to-date
(node:12824) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app: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.
Now I have the same problem on :
ionic info
cli packages: (C:\Users\hmishyn\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 7.0.0 browser 5.0.3 ios 4.5.4
Ionic Framework : ionic-angular 3.9.2
System:
Node : v6.13.0
npm : 3.10.10
OS : Windows 10
And my plugins:
ionic cordova plugins list
cordova plugin ls
cordova-android-support-gradle-release 1.2.0 "cordova-android-support-gradle-release"
cordova-open-native-settings 1.4.1 "Native settings"
cordova-plugin-device 2.0.1 "Device"
cordova-plugin-globalization 1.0.9 "Globalization"
cordova-plugin-ionic 4.0.0 "IonicCordova"
cordova-plugin-ionic-keyboard 2.0.5 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview"
cordova-plugin-platform-replace 1.0.0 "Platform String Replace"
cordova-plugin-scanbot-sdk 1.6.0 "Scanbot SDK Cordova Plugin"
cordova-plugin-secure-storage 2.6.8 "SecureStorage"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-whitelist 1.3.3 "Whitelist"
_phonegap-plugin-barcodescanner 7.0.4 "BarcodeScanner"_
_And problem really only in BarcodeScanner !_
How I know that? I delete this plugin, and after that project was built successfully => problem is with this plugin.
Hi to all. I fixed this problem. Steps:
ionic cordova plugin rm phonegap-plugin-barcodescannerionic cordova plugin add phonegap-plugin-barcodescannerionic cordova build android = successIt works for me !
I have been working on fixing this issue for almost a week and Im getting nowhere. Ive tried everything and nothing makes a difference. Im literally at my wits end.
Could someone who has fixed the issue please post the versions of 'Barcode Scanner' & 'Facebook4' they are running. Along with their ionic info.
I feel like i have already tried every conceivable combination aswell as attempting to edit the barcodescanner.gradle file.
Much love and thanks to anyone who can help.
@viking2917 @jfbloom22
I am traveling but will try to post info in next day or two.
On Thu, Apr 12, 2018, 3:36 PM Hayden Cassar notifications@github.com
wrote:
I have been working on fixing this issue for almost a week and Im getting
nowhere. Ive tried everything and nothing makes a difference. Im literally
at my wits end.Could someone who has fixed the issue please post the versions of 'Barcode
Scanner' & 'Facebook4' they are running. Along with their ionic info.I feel like i have already tried every conceivable combination aswell as
attempting to edit the barcodescanner.gradle file.Much love and thanks to anyone who can help.
@viking2917 https://github.com/viking2917 @jfbloom22
https://github.com/jfbloom22—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/phonegap/phonegap-plugin-barcodescanner/issues/606#issuecomment-380694589,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHVcVQ_4m8wMjDmv7S5Pfq8p5sTt-vu7ks5tnvXVgaJpZM4R0-aG
.
@viking2917 Thanks so much. Really appreciated.
Hello. I fixed this problem with barcode scanner on ver 7.1.0, but now I merge some branch with other plugins and it breaks again !
Now I have barcode scanner v. 7.1.1 and no “Facebook” plugin and I still get “unableToMergeDex” error. I have it ! I already spent 3-4 working days trying to solve this problem, but it happened again ! :(
On 12. Apr 2018, at 10:17, Hayden Cassar notifications@github.com wrote:
@viking2917 https://github.com/viking2917 Thanks so much. Really appreciated.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/phonegap/phonegap-plugin-barcodescanner/issues/606#issuecomment-380703338, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ_fYJ0wwHYpYdJe1k1Q9bXtvXm8SMMwks5tnv-FgaJpZM4R0-aG.
@Velm14 Im the same. Ive tried every combination of versions of Facebook4 & Barcodescanner and I still get 'unableToMergeDex'. Hopefully someone can help us out. Good luck.
Now I am trying to push app to AppStore, but when I built app for IOS, I got that it doesn’t work at all. Even it does not run camera… WTF with this plugin??? My ass is on fire !
On 12. Apr 2018, at 10:53, Hayden Cassar notifications@github.com wrote:
@Velm14 https://github.com/Velm14 Im the same. Ive tried every combination of versions of Facebook4 & Barcodescanner and I still get 'unableToMergeDex'. Hopefully someone can help us out. Good luck.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/phonegap/phonegap-plugin-barcodescanner/issues/606#issuecomment-380712095, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ_fYCJ9xINowI_IXrDbfb4xnCKGxGLtks5tnwgIgaJpZM4R0-aG.
@hcassar93 here's my info. Happy to provide more info if you want something specific.
First, I have noted that my app and environment at least is sensitive to the order of install of the plugins. if I install barcode scanner first it barfs..
I install Facebook (v.1.7.4) (then other plugins such as Push), make sure I add the android platform after all that. then I install other plugins, and near the the end the barcode scanner
ionic cordova plugin add [email protected] --save --variable APP_ID="
ionic cordova plugin add [email protected]; npm install --save @ionic-native/push
.....
ionic cordova plugin add phonegap-plugin-barcodescanner; npm install --save @ionic-native/barcode-scanner
Because of various conflicts on plugins (I think unrelated to barcode scanner), I have to edit my project.properties file to set:
cordova.system.library.4=com.google.android.gms:play-services-analytics:11.6.2
But again I think that's unrelated to the barcode scanner.
The way I got this to work, I created a clean ionic project and just tried to get it to build with no other components, googling for answers when I had problems. I just kept a log of the order I did stuff and the redid it in my project in that order.
Details:
Here's my plugin list:
(in particular,
cordova-plugin-facebook4 1.7.4 "Facebook Connect"
and
phonegap-plugin-barcodescanner 7.0.2 "BarcodeScanner"
)
ionic cordova plugin list
cordova plugin ls
com-darryncampbell-cordova-plugin-intent 1.0.0 "Intent Shim"
com.web-mystery.cordova.openwith-ios 1.0.0 "OpenWith"
cordova-fabric-plugin 1.1.13-dev "cordova-fabric-plugin"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-apprate 1.3.0 "AppRate"
cordova-plugin-camera 4.0.3-dev "Camera"
cordova-plugin-contacts 3.0.1 "Contacts"
cordova-plugin-device 2.0.1 "Device"
cordova-plugin-dialogs 2.0.1 "Notification"
cordova-plugin-email-composer 0.8.15 "EmailComposer"
cordova-plugin-facebook4 1.7.4 "Facebook Connect"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-file-transfer 1.7.1 "File Transfer"
cordova-plugin-globalization 1.0.9 "Globalization"
cordova-plugin-google-analytics 1.8.3 "Google Universal Analytics Plugin"
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-media 5.0.2 "Media"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-whitelist 1.3.3 "Whitelist"
phonegap-plugin-barcodescanner 7.0.2 "BarcodeScanner"
phonegap-plugin-push 2.1.3 "PushPlugin"
output of ionic info
ionic info
cli packages: (/Users/markwatkins/.nvm/versions/node/v8.9.4/lib/node_modules)
@ionic/cli-utils : 1.19.1
ionic (Ionic CLI) : 3.19.1
global packages:
cordova (Cordova CLI) : 8.0.0
Gulp CLI : CLI version 3.9.1 Local version 3.9.1
local packages:
Cordova Platforms : android 7.0.0 ios 4.5.4
Ionic Framework : ionic1 1.3.3
System:
Android SDK Tools : 26.1.1
ios-deploy : 1.9.2
Node : v8.9.4
npm : 5.6.0
OS : macOS High Sierra
Xcode : Xcode 9.3 Build version 9E145
Environment Variables:
ANDROID_HOME : /Users/markwatkins/Library/Android/sdk
Misc:
backend : pro
@hcassar93 To make it work I am running:
cli packages: (/Users/rogier/DEV/embrosa_v3/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 7.0.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 : v8.9.4
npm : 5.7.1
OS : macOS High Sierra
Xcode : Xcode 9.3 Build version 9E145
Hopefully this will help you?
@hcassar93 looking through trying to see if there is any pattern between the various versions of plugins and Cordova and what not. Can you share your setup?
@ivanosire mentioned that a fix was merged into version 7.0.3.
Has anyone tried that?
This fix was similar to my solution above, but looks more correct: https://github.com/phonegap/phonegap-plugin-barcodescanner/commit/16c97b7b6d0f845282d0633e65593ac263baaa58 Basically they moved the requirement for the support v4 framework from he gradle file to plugin.xml file. The facebook plugin also has a plugin.xml file and requires the android v4 framework. Line 64: <framework src="com.facebook.android:facebook-android-sdk:4.+"/>
I'm using the barcodescanner in my Ionic app (together with the facebook plugin). Here is, what I have done to get it working:
I hope this helps someone!
cordova clean
1 line fix bug
When I saw @mgreg89 's comment, I thought: "I don't wanna do all that crap!" so I started with #4 cordova clean and it worked. I didn't even see @hiepxanh 's comment until now.
Ps there is no Facebook plugin in my app. I found several posts about this error & they all were regarding Fb plugin and they also all had the BarcodeScanner plugin which is what I added before it stopped working.
@mgreg89 Those 4 steps did it for me. Thank you!
Thank you, now also cordova.plugins.diagnostic works fine!
Agregar a build.gradle
buildscript {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
allprojects {
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}
}
Y listo!
I got same error message:
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
And I have managed to fix it so I am writing this fix because I have not find it on the internet...
To me looks like that that facebook plugin was not the only one making problem... but one of my plugins also added reference to appcompat library.... Aparently barcodescanner plugin uses this barcodescanner-lib-aar whcih depends on appcompat:26.0.2, so I edited projects.properties file like this:
target=android-26
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.system.library.1=com.android.support:appcompat-v7:26+
cordova.system.library.2=com.android.support:support-v4:27.+
cordova.system.library.3=com.google.android.gms:play-services-auth:11.8.0
cordova.system.library.4=com.google.android.gms:play-services-identity:11.8.0
cordova.system.library.5=com.facebook.android:facebook-android-sdk:4.14.+
cordova.gradle.include.1=cordova-plugin-telerik-imagepicker/starter-ignorelinterrors.gradle
cordova.gradle.include.2=cordova-plugin-telerik-imagepicker/starter-androidtarget.gradle
cordova.gradle.include.3=phonegap-plugin-barcodescanner/starter-barcodescanner.gradle
I put this project.properties in resources/android folder and added this entry to config.xml
<resource-file src="resources/android/project.properties" target="project.properties" />
Be careful with this when adding next plugin, because this line will always override that project.properties inside platforms/android folder, so updated it every time you install new plugin
These are my plugins:
<plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
<plugin name="cordova-plugin-device" spec="^2.0.2" />
<plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
<plugin name="cordova-plugin-ionic-webview" spec="^1.1.19" />
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
<plugin name="cordova-plugin-statusbar" spec="^2.4.2" />
<plugin name="cordova-plugin-geolocation" spec="^4.0.1">
<variable name="GEOLOCATION_USAGE_DESCRIPTION" value="..." />
</plugin>
<plugin name="cordova-plugin-telerik-imagepicker" spec="^2.2.1">
<variable name="PHOTO_LIBRARY_USAGE_DESCRIPTION" value="..." />
</plugin>
<plugin name="cordova-plugin-file-transfer" spec="^1.7.1" />
<plugin name="cordova-plugin-x-socialsharing" spec="^5.4.0" />
<plugin name="cordova-sqlite-storage" spec="^2.3.2" />
<plugin name="phonegap-plugin-barcodescanner" spec="^8.0.0">
<variable name="ANDROID_SUPPORT_V4_VERSION" value="27.+" />
</plugin>
<plugin name="cordova-plugin-facebook4" spec="^1.7.4">
<variable name="APP_ID" value="..." />
<variable name="APP_NAME" value="..." />
</plugin>
<plugin name="cordova-plugin-googleplus" spec="^5.3.0">
<variable name="REVERSED_CLIENT_ID" value="..." />
</plugin>
<engine name="android" spec="7.0.0" />
run cordova clean and cordova build android and everything works fine
I have been dealing with the conflict between barcodescanner plugin and facebook4 plugin for 2 days now reading and applying all suggestions without success, and just now I was able to build it successfully on Android, following these steps:
cordova clean from @hiepxanh
works for me. not using barcode scanner. but got this error. so tried cordova clean and it can compile fine
@Velm14 Fixed.
Thanks
same problem here...
In my case https://stackoverflow.com/a/49274288/7490381 was a solution.
I can scan barcode but when I try to scan barcode, It's not scan.
Please help.
Closing as duplicate of https://github.com/phonegap/phonegap-plugin-barcodescanner/issues/535
This thread has been automatically locked.
Most helpful comment
cordova clean1 line fix bug