Phonegap-plugin-barcodescanner: How to solve Program type already present: com.google.zxing.BarcodeFormat in ionic 4

Created on 28 Sep 2019  路  12Comments  路  Source: phonegap/phonegap-plugin-barcodescanner

I am using ionic 4. When my project have facebook plugin and BarcodeScanner plugin and type ionic cordova run android, it will come out this error:

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 unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
D8: Program type already present: com.google.zxing.BarcodeFormat

FAILURE: Build failed with an exception.

* 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.
I download both plugin using these command:

ionic cordova plugin add phonegap-plugin-barcodescanner
npm install @ionic-native/barcode-scanner

ionic cordova plugin add cordova-plugin-facebook4 --variable APP_ID="app_id" --variable APP_NAME="app_name"
npm install --save @ionic-native/facebook
stale

Most helpful comment

Exactly the same issue. How can I deactivate the zxing in this plugin?

All 12 comments

Exactly the same issue. How can I deactivate the zxing in this plugin?

Same issue here

Same issue. Please respond

Same here....

D8: Program type already present: com.google.zxing.BarcodeFormat

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: com.google.zxing.BarcodeFormat

En mi caso descubrimos junto a un amigo que el conflicto lo genera un plugin, seguramente tienen mas de un plugin instalado. en mi caso era que tenia este npm uninstall cordova-plugin-facebook4 que no lo estaba usando...

@Mitnick21 yes I've just found the same problem. it's conflict with cordova-plugin-facebook4.
I tried to solve it for 3 days but it seems impossible.

Hi,
I've just found the same problem. I found a plugin that works well with phonegap-plugin-barcodescanner. This is: cordova-plugin-facebook4-no-zxing
I hope it helps.

Gente no deben usar cordova-plugin-facebook4-no-zxing por algun motivo no funciona yo segui este tutorial y no tuve problemas https://www.npmjs.com/package/angularx-social-login deben desinstalar el facebook4 con el comando npm uninstall cordova-plugin-facebook4

espero sirva...

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

here ist another solution if you don't want to install cordova-plugin-facebook4-no-zxing https://www.gitmemory.com/issue/jeduan/cordova-plugin-facebook4/777/517428763

1.Remove android platform.
2.Install cordova-plugin-facebook4
3.Create build.gradle in /plugins/cordova-plugin-facebook4/
4.Copy this
dependencies { compile("com.facebook.android:facebook-android-sdk:4.37.0") { exclude group: 'com.google.zxing' } }
to ../plugins/cordova-plugin-facebook4/build.gradle
5.Edit ../plugins/cordova-plugin-facebook4/plugins.xml change
<framework src="com.facebook.android:facebook-android-sdk:$FACEBOOK_ANDROID_SDK_VERSION"/>
to
<framework src="build.gradle" custom="true" type="gradleReference"/>
6.Add platform android and build

@ngongocdung Thank you for your reply. I will try it

here ist another solution if you don't want to install cordova-plugin-facebook4-no-zxing https://www.gitmemory.com/issue/jeduan/cordova-plugin-facebook4/777/517428763

1.Remove android platform.
2.Install cordova-plugin-facebook4
3.Create build.gradle in /plugins/cordova-plugin-facebook4/
4.Copy this
dependencies { compile("com.facebook.android:facebook-android-sdk:4.37.0") { exclude group: 'com.google.zxing' } }
to ../plugins/cordova-plugin-facebook4/build.gradle
5.Edit ../plugins/cordova-plugin-facebook4/plugins.xml change
<framework src="com.facebook.android:facebook-android-sdk:$FACEBOOK_ANDROID_SDK_VERSION"/>
to
<framework src="build.gradle" custom="true" type="gradleReference"/>
6.Add platform android and build

@ngongocdung Thank you so much, it worked without problems! I Searched for hours before ...

Was this page helpful?
0 / 5 - 0 ratings