简体   繁体   中英

ionic facebook and barcodescanner issue

I have a problem with facebook plugin and barcode scanner, first i created a projects separate to check how facebook plugin work and was working perfect, but when I added the facebook plugin to my project where im using barcodescanner plugin i cant run the project in android, I got the following exception:

 BUILD FAILED

Total time: 10.111 secs
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/BarcodeFormat.class

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error: cmd: 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 ':transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/zxing/BarcodeFormat.class

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

[ERROR] An error occurred while running cordova run android (exit code 1).

Step 1 : Install Barcode Scanner Plugin:

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

Step 2: Install Facebook plugin: (Use the below facebook plugin version)

ionic cordova plugin add cordova-plugin-facebook4@1.7.4 --variable APP_ID="****" --variable APP_NAME="****"
npm install --save @ionic-native/facebook

Step 3: Open the file facebookconnect.xml from this path : yourapp\\platforms\\android\\app\\src\\main\\res\\values and add two lines inside <resources></resources>

<resources>
  <string name="fb_app_id">***your_app_id***</string>
  <string name="fb_app_name">***your_app_name***</string>
</resources>

Step 4: Command : cordova clean - allow cordova clean your app

Step 5: Command : cordova build - check cordova build your app

Step 6: Command : ionic cordova build android - Build your app

更改所需的Facebook插件版本可以为我解决此问题。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM