Multiple dex files define Lorg/apache/cordova/BuildHelper
Going to add my 2 cents since none of the solutions work for me. Only thing that worked for me:
cordova plugin rm cordova-plugin-compat --force
cordova platform rm android
cordova platform add android@6.3.0
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.
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