ionic3 安装了 barcodeScanner 插件之后,打包报错
Execution failed for task ':app:transformDexWithDexForRelease'.
执行的步骤为:
添加插件
ionic cordova plugin add phonegap-plugin-barcodescanner --save --variable CAMERA_USAGE_DESCRIPTION="To scan barcodes"
npm 安装依赖包
npm install --save @ionic-native/barcode-scanner
服务可以正常启动
打包的时候报错
ionic cordova build android --prod --release
文字版报错:
:app:transformDexWithDexForRelease
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/app/FragmentTransitionCompat21$1;
* 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:10316) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files def
* 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
所用的环境为:
package.json 上面的版本:
"phonegap-plugin-barcodescanner": "^7.1.2",
ionic: 3.20.0
gradle: 4.2
应该是android打包环境的问题