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 [email protected]
I had to do:
cordova plugin rm cordova-plugin-compat --force
cordova plugin add [email protected]
cordova platform rm android
cordova platform add [email protected]
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 [email protected]
, 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 [email protected]
which includes an engine constraint to prevent the Java files being re-installed into the [email protected]+
platform:
cordova plugin add [email protected]
Another update (copypasted from comments)
After removing and adding [email protected], instead of removing and adding entire Android platform you can only remove files BuildHelper.java and PermissionHelper.java from folder platforms/android