微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – 多个dex文件定义Lorg / apache / cordova / BuildHelper

我从昨天开始遇到麻烦了.在我的实习中,我遇到了以下构建错误,但我无法理解为什么:

$cordova build android

[...]

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 Lorg/apache/cordova/BuildHelper;

* 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: 3.379 secs
Error: /home/thor/Projects/App_CDP/platforms/android/gradlew: 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.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

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 Lorg/apache/cordova/BuildHelper;

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

这是cordova插件列表的输出,我没有support-v4 / v13冲突,你可以看到:

$cordova plugin list
com.googlemaps.ios 2.2.0-fixed "Google Maps SDK for iOS"
com.moust.cordova.videoplayer 1.0.1 "Video Player"
cordova-plugin-camera 2.4.1 "Camera"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-console 1.0.5 "Console"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-facebook4 1.9.1 "Facebook Connect"
cordova-plugin-file 4.0.0 "File"
cordova-plugin-file-transfer 1.6.3 "File Transfer"
cordova-plugin-geolocation 2.4.3 "Geolocation"
cordova-plugin-googlemaps 1.4.0 "phonegap-googlemaps-plugin"
cordova-plugin-inappbrowser 1.7.1 "InAppbrowser"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.2 "StatusBar"
cordova-plugin-whitelist 1.3.1 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"
{}

这里还有一些更多的信息:

$cordova -v
7.0.1

$ionic -v
2.1.4

解决方法:

您最有可能使用新发布的cordova-android@6.3.0,现在包含BuildHelper.java(如您的错误消息中所述)和PermissionHelper.java,但您的项目中仍然使用了已弃用的cordova-plugin-compat,导致构建失败,因为它also contains these classes.

解决此问题,请从项目中删除cordova-plugin-compat以从cordova-android平台项目中卸载这些Java文件::

cordova plugin rm cordova-plugin-compat --force

更新

要保留此更改,请添加cordova-plugin-compat@1.2,其中包含engine constraint,以防止将Java文件重新安装到cordova-android@6.3平台中:

cordova plugin add cordova-plugin-compat@1.2

一个更新(从评论中复制)

删除添加cordova-plugin-compat@1.2后,您只能从文件夹平台/ android中删除文件BuildHelper.java和PermissionHelper.java,而不是删除添加整个Android平台

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐