BarcodeScanner & Facebook4 Plugins Not Compatible?

Hey All. Im in Cordova hell. More than a week and Ive made literally no progress.

When using the BarcodeScanner ionic native plugin and Facebook4 plugins separately they work fine. However together they wont build for Android (they build fine for iOS however android throws error)

Error:Execution failed for task ‘:app:transformDexArchiveWithExternalLibsDexMergerForDebug’.

java.lang.RuntimeException:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex).

Apparently the facebook plugin includes the facebook sdk which includes a library that is used by many other Android SDK’s. Issue about this on github; https://github.com/phonegap/phonegap-plugin-barcodescanner/issues/606. However ive tried everything off here.

Anyone have these two plugins working together?

If so could you post what versions your running aswell as your ionic info?

Thanks and much love to anyone who can help.
Hayden

2 Likes

I am facing the same issue with those two plugins. Getting build error with latest cordova-plugin-facebook4 plugin.

I found a workaround – I have successfully build with cordova-plugin-facebook4@1.7.4

I’m struggling with the same issue.

I’ve tried all the fixes listed in all the StackOverflow threads about this and all the Github Issues threads also.

I’ve even tried iamdevsaikat’s fix but still I get errors.

Has anyone beaten this?

FIX EDIT:

Ok I got this working… I used iamdevsaikat’s fix by using Facebook Native Plugin Version 1.74

I ran this:

ionic cordova rm android

Then:

ionic cordova plugin add cordova-plugin-facebook4@1.7.4 -save --variable APP_ID="MY_FB_APP_ID" --variable APP_NAME="MY_FB_APP_NAME"

Then I ran:

ionic cordova platform add android@7.1.0

NOTE: the build failed on Android version 7.0.0 (which my ionic was getting by default) but works well on 7.1.0

Root cause seems to come from barcode scanner plugin.

The error message is not exactly the same but cause yes.

Quick fix:

cordova platform remove android

add the following in /plugins/phonegap-plugin-barcodescanner/src/android/barcodescanner.gradle

configurations {
    compile.exclude group: 'com.google.zxing'
}

cordova platform add android

3 Likes