gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 11:07:43 31 4
gpt4 key购买 nike

从昨天开始我就有麻烦了。在我的实习中,我遇到了以下构建错误,但我不明白为什么:

$ 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

最佳答案

您很可能正在使用新发布的 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后,您只能从文件夹platforms/android中删除文件BuildHelper.java和PermissionHelper.java,而不是删除和添加整个Android平台

关于android - 多个 dex 文件定义 Lorg/apache/cordova/BuildHelper,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46562289/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com