ionic打包报错 ':app:transformDexWithDexForRelease'

ionic3 安装了 barcodeScanner 插件之后,打包报错
Execution failed for task ':app:transformDexWithDexForRelease'.
clipboard.png

执行的步骤为:

添加插件

ionic cordova  plugin add phonegap-plugin-barcodescanner --save --variable CAMERA_USAGE_DESCRIPTION="To scan barcodes"

clipboard.png

npm 安装依赖包

npm install --save @ionic-native/barcode-scanner

clipboard.png

服务可以正常启动

clipboard.png

打包的时候报错

ionic cordova build android --prod --release 

clipboard.png
文字版报错:

: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



阅读 2.9k
1 个回答

应该是android打包环境的问题

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进