IONIC Build失败了transformClassesWithDexForDebug

时间:2017-08-30 19:45:57

标签: android cordova sdk ionic2

我试图在我的Android设备上运行我的IONIC应用程序运行命令ionic cordova运行android --device。但是当它建造时,cordova会返回此错误

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformClassesWithDexForDebug'.
> 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;

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

BUILD FAILED

Total time: 51.779 secs
Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformClassesWithDexForDebug'.
> 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;

* 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 --device (exit code1).

cordova plugin ls的输出:

com.synconset.imagepicker 2.1.8 "ImagePicker"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-console 1.0.5 "Console"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-dialogs 1.3.3 "Notification"
cordova-plugin-facebook4 1.9.1 "Facebook Connect"
cordova-plugin-geolocation 2.4.3 "Geolocation"
cordova-plugin-google-analytics 1.8.3 "Google Universal Analytics Plugin"
cordova-plugin-googleplus 5.1.1 "Google SignIn"
cordova-plugin-nativestorage 2.2.2 "NativeStorage"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.1 "StatusBar"
cordova-plugin-whitelist 1.3.1 "Whitelist"
cordova-plugin-x-socialsharing 5.1.8 "SocialSharing"
es6-promise-plugin 4.1.0 "Promise"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-plugin-barcodescanner 6.0.8 "BarcodeScanner"
phonegap-plugin-push 1.10.5 "PushPlugin"

2 个答案:

答案 0 :(得分:1)

我有同样的问题和几乎相同的设置。您是否尝试将project_name > templates > app_name > template_name.html恢复为1.7.4版本?

对我而言,这不是一个解决方案,但它现在是一种解决方法,只是为了构建应用程序。

如果还原插件会为您修复,请查看https://github.com/phonegap/phonegap-plugin-barcodescanner/issues/535

答案 1 :(得分:0)

转到平台 - > android - > build.gradle

在defaultConfig下添加multiDexEnabled true,如下所示

defaultConfig {
    multiDexEnabled true
}

这对我有用..

https://forum.ionicframework.com/t/help-with-build-failed-android-ionic/94396/8