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

2024-01-08

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

$ 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 plugins list,我没有 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

您很可能正在使用新发布的[email protected] /cdn-cgi/l/email-protection,现在包括构建助手.java https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/BuildHelper.java(如您的错误消息中所述)和PermissionHelper.java https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/PermissionHelper.java,但你仍然有已弃用的科尔多瓦插件兼容 https://github.com/apache/cordova-plugin-compat在您的项目中,这导致构建失败,因为它还包含这些类 https://github.com/apache/cordova-plugin-compat/tree/master/src/android.

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

cordova plugin rm cordova-plugin-compat --force

Update

要保留此更改,请添加[email protected] /cdn-cgi/l/email-protection其中包括一个发动机约束 https://github.com/apache/cordova-plugin-compat/blob/master/plugin.xml#L29以防止 Java 文件被重新安装到[email protected] /cdn-cgi/l/email-protection+平台:

cordova plugin add [email protected] /cdn-cgi/l/email-protection

另一个更新(评论里复制粘贴的)

删除并添加后[电子邮件受保护] /cdn-cgi/l/email-protection,您只能从文件夹platforms/android中删除文件BuildHelper.java和PermissionHelper.java,而不是删除和添加整个Android平台

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

多个 dex 文件定义 Lorg/apache/cordova/BuildHelper 的相关文章

随机推荐