多个dex文件定义了Lorg/apache/cordova/BuildHelper [英] Multiple dex files define Lorg/apache/cordova/BuildHelper

查看:26
本文介绍了多个dex文件定义了Lorg/apache/cordova/BuildHelper的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm in trouble since yesterday. In my internship I faced the following build error, but I couldn't understand why :

$ 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冲突:

Here is the output of cordova plugins list, I don't have the support-v4/v13 conflict as you can see :

$ 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"
{}

这里还有一些更多信息:

Here are also some more informations:

$ cordova -v
7.0.1

$ ionic -v
2.1.4

推荐答案

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

Most likely you are using the newly released cordova-android@6.3.0, which now includes BuildHelper.java (as noted in your error message) and PermissionHelper.java, but you still have the deprecated cordova-plugin-compat in your project which is causing the build to fail because it also contains these classes.

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

To fix this, remove cordova-plugin-compat from your project to uninstall these Java files from the cordova-android platform project::

cordova plugin rm cordova-plugin-compat --force

更新

要保持此更改,请添加 cordova-plugin-compat@1.2,其中包含一个 引擎约束,以防止将 Java 文件重新安装到 cordova-android@6.3+ 平台:

To persist this change add cordova-plugin-compat@1.2 which includes an engine constraint to prevent the Java files being re-installed into the cordova-android@6.3+ platform:

cordova plugin add cordova-plugin-compat@1.2

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

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

After removing and adding cordova-plugin-compat@1.2, instead of removing and adding entire Android platform you can only remove files BuildHelper.java and PermissionHelper.java from folder platforms/android

这篇关于多个dex文件定义了Lorg/apache/cordova/BuildHelper的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆