Skip to content
This repository has been archived by the owner on Oct 24, 2022. It is now read-only.

Facebook Android SDK import ZXing, breaks cordova build when combined with phonegap-plugin-barcodescanner #550

Closed
dxiao2003 opened this issue Aug 25, 2017 · 14 comments

Comments

@dxiao2003
Copy link

The latest version of the Facebook Android SDK (4.26.0) includes the ZXing barcode scanner library as a dependency. When I try to build a project on Android that includes both cordova-plugin-facebook4 and phonegap-plugin-barcodescanner, I get a multiple Dex error:

Execution failed for task ':transformClassesWithDexForArmv7Debug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/zxing/BarcodeFormat;

I'm not an expert on Gradle builds but maybe it's possible to add a line that forces the zxing library to be imported only if it's not already imported elsewhere, so that we don't end up with two copies of the library?

@yosi-dediashvili
Copy link

yosi-dediashvili commented Aug 26, 2017

See fix (at least for now): phonegap/phonegap-plugin-barcodescanner#535 (comment)

@ipehimanshu
Copy link

we are using phonegap build site to create build

Here is our config

<preference name="phonegap-version" value="cli-7.0.1" />

and we use below plugins

<plugin name="cordova-plugin-facebook4" spec="^1.9.1" source="npm"> <variable name="APP_ID" value="xxxxxxxxxxxxxx" /> <variable name="APP_NAME" value="xxxxxxxxxx" /> </plugin>

`<plugin name="cordova-android-support-gradle-release" spec="0.0.2" source="npm">
    <variable name="ANDROID_SUPPORT_VERSION" value="25.+" />
</plugin>`

`<plugin name="phonegap-plugin-barcodescanner" spec="6.0.8" source="npm">
    <variable name="CAMERA_USAGE_DESCRIPTION" value="To scan barcodes." />
</plugin>`

`<plugin spec="https://github.com/NazarKozak/cordova-plugin-multidex.git" source="git" />`

We get this type error

from phonegap build url

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':transformClassesWithJarMergingForDebug'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/zxing/aztec/AztecDetectorResult.class

So any one please help me to resolve this issue ?

@shinigarek
Copy link

Hello

I am using ionic and integré facebook and barcodescanner and I have the reported error. I have not been able to solve the problem in any way.

Please help

@shinigarek
Copy link

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_cn1pcwr1c1efi8eowabf90t4k.run(/home/eobreque/Documents/ezequiel/virtual-v2/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
:app:compileDebugAidl 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
UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest
UP-TO-DATE
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources
UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:javaPreCompileDebug UP-TO-DATE
:app:compileDebugJavaWithJavac
UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
:app:compileDebugSources UP-TO-DATE
: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
UP-TO-DATE
:app:extractTryWithResourcesSupportJarDebug UP-TO-DATE
:app:transformClassesWithStackFramesFixerForDebug
UP-TO-DATE

:app:transformClassesWithDesugarForDebug

UP-TO-DATE
:app:transformClassesWithDexBuilderForDebug
UP-TO-DATE
: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 2s
38 actionable tasks: 1 executed, 37 up-to-date
(node:13073) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: /home/eobreque/Documents/ezequiel/virtual-v2/platforms/android/gradlew: 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.

  • Get more help at https://help.gradle.org

BUILD FAILED in 2s

@shinigarek
Copy link

{
"name": "virtual-2",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"@angular/animations": "^5.1.2",
"@angular/common": "5.0.3",
"@angular/compiler": "5.0.3",
"@angular/compiler-cli": "5.0.3",
"@angular/core": "5.0.3",
"@angular/forms": "5.0.3",
"@angular/http": "5.0.3",
"@angular/platform-browser": "5.0.3",
"@angular/platform-browser-dynamic": "5.0.3",
"@ionic-native/barcode-scanner": "^4.5.3",
"@ionic-native/core": "4.4.0",
"@ionic-native/facebook": "^4.5.2",
"@ionic-native/geolocation": "^4.5.2",
"@ionic-native/google-plus": "^4.5.2",
"@ionic-native/splash-screen": "4.4.0",
"@ionic-native/status-bar": "4.4.0",
"@ionic/pro": "1.0.16",
"@ionic/storage": "2.1.3",
"chilean-rut": "^1.0.24",
"commonjs": "0.0.1",
"cordova-plugin-compat": "^1.2.0",
"cordova-plugin-device": "^1.1.7",
"cordova-plugin-facebook4": "^1.9.1",
"cordova-plugin-geolocation": "^3.0.0",
"cordova-plugin-googleplus": "^5.2.1",
"cordova-plugin-ionic-webview": "^1.1.16",
"cordova-plugin-splashscreen": "^4.1.0",
"cordova-plugin-whitelist": "^1.3.3",
"ionic-angular": "3.9.2",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"ng2-charts": "^1.6.0",
"ngx-qrcode2": "0.0.5",
"phonegap-plugin-barcodescanner": "^7.0.2",
"rxjs": "5.5.2",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.18",
"cordova-android": "~7.0.0"
},
"devDependencies": {
"@ionic/app-scripts": "3.1.6",
"typescript": "2.4.2"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"ionic-plugin-keyboard": {},
"cordova-plugin-whitelist": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-geolocation": {
"GEOLOCATION_USAGE_DESCRIPTION": "Localizar Iglesias"
},
"cordova-plugin-facebook4": {
"APP_ID": "333325963746280",
"APP_NAME": "bishop"
},
"cordova-plugin-googleplus": {
"REVERSED_CLIENT_ID": "myreversedclientid"
},
"phonegap-plugin-barcodescanner": {
"CAMERA_USAGE_DESCRIPTION": " "
},
"cordova-plugin-compat": {}
},
"platforms": [
"android"
]
}
}

@shinigarek
Copy link

help please ... Has anyone been able to solve this problem?

@lovetheidea
Copy link

lovetheidea commented Feb 17, 2018

Fixed by changing .xml:

<platform name="android">
<framework src="com.facebook.android:facebook-android-sdk:4.25.0" />
</platform>

cordova platform rm android
cordova platform add android

solutions on: 535

@skaman
Copy link

skaman commented Apr 18, 2018

With pull request #646 you can set the SDK version without changing the XML.

Ex:
cordova plugin add cordova-plugin-facebook4 --save --variable APP_ID="123456789" --variable APP_NAME="myApplication" --variable ANDROID_SDK_VERSOIN="4.25.0"

@kumarom1203
Copy link

cordova plugin add cordova-plugin-facebook4 --save --variable APP_ID="xxxxxxxxxxx" --variable APP_NAME="XXXXXXXXX" --variable ANDROID_SDK_VERSOIN="4.25.0"
WITH
ionic cordova plugin add phonegap-plugin-barcodescanner

BUT AGAIN GETTING BUILD ERROR.. ANY ONE CAN HELP ME PLEASE
plerror

@skaman
Copy link

skaman commented Apr 21, 2018

@kumarom1203 sorry my bad. That command will not work until they accept the pull request (if they will).
In the meantime you can temporary use my repo:

cordova plugin add https://github.com/ideaful/cordova-plugin-facebook4.git --save --variable APP_ID="123456789" --variable APP_NAME="myApplication" --variable ANDROID_SDK_VERSION="4.25.0"

If you still have the issue after adding the plugin, please try to remove the re-add the platform

@peterpeterparker
Copy link
Collaborator

peterpeterparker commented Apr 21, 2018

@skaman I'll accept the PR soon

@peterpeterparker
Copy link
Collaborator

peterpeterparker commented Apr 21, 2018

PR #646 merged. Android guide updated.

For support questions use Stackoverflow, Ionic forum or other channels

@peterpeterparker
Copy link
Collaborator

@skaman PR has been published to npm too

@redplane
Copy link

redplane commented Apr 20, 2019

Same issue, even in 2019 :|
This is the command I have used:

ionic cordova plugin add cordova-plugin-facebook4 --save --variable APP_ID="<my-app-id>" --variable APP_NAME="<my-app-name>" --variable FACEBOOK_ANDROID_SDK_VERSION="4.41.0"

Any solution please ?

-- UPDATE --

I had to use the plugin:

https://github.com/AndreiTelteu/cordova-plugin-facebook4-no-zxing and it worked.

@peterpeterparker , can you add any additional parameters or variables to ignore zxing while adding plugin ? Or on document, should it be updated https://github.com/AndreiTelteu/cordova-plugin-facebook4-no-zxing for those who is facing the same issue as we do ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants