ionic facebook 和 barcodescanner 问题
ionic facebook and barcodescanner issue
我在使用 facebook 插件和条形码扫描仪时遇到问题,首先我单独创建了一个项目来检查 facebook 插件如何工作并且运行良好,但是当我将 facebook 插件添加到我使用 barcodescanner 插件的项目时我无法运行 android 中的项目,出现以下异常:
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).
更改所需的 Facebook 插件版本解决了我的问题。
ionic cordova plugin add cordova-plugin-facebook4@1.7.4 --variable APP_ID="" --variable APP_NAME=""
第 1 步:安装条码扫描器插件:
$ ionic cordova plugin add phonegap-plugin-barcodescanner
$ npm install --save @ionic-native/barcode-scanner
第二步:安装Facebook插件:(使用以下facebook插件版本)
ionic cordova plugin add cordova-plugin-facebook4@1.7.4 --variable APP_ID="****" --variable APP_NAME="****"
npm install --save @ionic-native/facebook
第 3 步:从此路径打开文件 facebookconnect.xml
:yourapp\platforms\android\app\src\main\res\values
并在 <resources></resources>
中添加两行
<resources>
<string name="fb_app_id">***your_app_id***</string>
<string name="fb_app_name">***your_app_name***</string>
</resources>
第 4 步:命令:cordova clean
- 允许 cordova 清理您的应用程序
第 5 步:命令:cordova build
- 检查 cordova 构建您的应用程序
第 6 步:命令:ionic cordova build android
- 构建您的应用程序
我在使用 facebook 插件和条形码扫描仪时遇到问题,首先我单独创建了一个项目来检查 facebook 插件如何工作并且运行良好,但是当我将 facebook 插件添加到我使用 barcodescanner 插件的项目时我无法运行 android 中的项目,出现以下异常:
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).
更改所需的 Facebook 插件版本解决了我的问题。
ionic cordova plugin add cordova-plugin-facebook4@1.7.4 --variable APP_ID="" --variable APP_NAME=""
第 1 步:安装条码扫描器插件:
$ ionic cordova plugin add phonegap-plugin-barcodescanner
$ npm install --save @ionic-native/barcode-scanner
第二步:安装Facebook插件:(使用以下facebook插件版本)
ionic cordova plugin add cordova-plugin-facebook4@1.7.4 --variable APP_ID="****" --variable APP_NAME="****"
npm install --save @ionic-native/facebook
第 3 步:从此路径打开文件 facebookconnect.xml
:yourapp\platforms\android\app\src\main\res\values
并在 <resources></resources>
<resources>
<string name="fb_app_id">***your_app_id***</string>
<string name="fb_app_name">***your_app_name***</string>
</resources>
第 4 步:命令:cordova clean
- 允许 cordova 清理您的应用程序
第 5 步:命令:cordova build
- 检查 cordova 构建您的应用程序
第 6 步:命令:ionic cordova build android
- 构建您的应用程序