Multiple dex files define Lorg/apache/cordova/BuildHelper

前端 未结 17 1568
梦如初夏
梦如初夏 2020-11-29 01:57

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         


        
相关标签:
17条回答
  • 2020-11-29 02:22

    I had to do:

    cordova plugin rm cordova-plugin-compat --force
    cordova plugin add cordova-plugin-compat@1.2
    cordova platform rm android
    cordova platform add android@6.3.0
    

    considering you can't simply remove cordova-plugin-compat because plugins like cordova-plugin-file depend on it.

    0 讨论(0)
  • 2020-11-29 02:31

    I have remove the Compat plugin after the update the dependency of other plugins; like Camera to the new version and it's work. Example: cordova plugin rm cordova-plugin-camera --save cordova plugin add cordova-plugin-camera@latest --save Post the new plugin addition the old version 2.3.0 was replaced with 4.0.2 for Camera plugin.

    after this step. I have simply remove the plugin "Compat" cordova plugin rm cordova-plugin-compat --force

    0 讨论(0)
  • 2020-11-29 02:31

    On Resume. This mean that plugin-camera is not compatible with the last version of android oreo

    0 讨论(0)
  • 2020-11-29 02:32

    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.

    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
    

    Update

    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
    

    Another update (copypasted from comments)

    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

    0 讨论(0)
  • 2020-11-29 02:32

    I am using Ionic 4 and this solved it for me (only takes a few seconds to run):

    cordova clean
    
    0 讨论(0)
提交回复
热议问题