I am using Cordova CLI 9.0, Cordova-Android 9.0, and an Ionic 4 Web application. It runs okay, but I keep getting these errors for my plugins:
"Uncaught module cordova-plugin-splashscreen.SplashScreen already defined"
"Uncaught module cordova-plugin-statusbar.statusbar already defined"
"Uncaught module org.apache.cordova.plugin.bluetooth.bluetooth already defined"
"Uncaught module cordova-plugin-geolocation.geolocation already defined"
"Uncaught module cordova-plugin-device.device already defined"
"Uncaught module org.apache.cordova.plugin.platformevent.platformEvent"
"Uncaught module de.fastr.phonegap.plugins.injectView.inject already defined"
"Uncaught module org.apache.cordova.plugin.platformevent.msrEvent already defined"
"Uncaught module cordova-plugin-screen-orientation.screenorientation"
"Uncaught module cordova-plugin-geolocation.PositionError already defined"
"Uncaught module cordova-plugin-inappbrowser.inappbrowser already defined"
I've already looked at multiple stackoverflow questions, including the 2 posted below, and neither seemed to be my issue:
Cordova plugin error: "Uncaught module ... already defined"
Error in Phonegap Application: Uncaught module cordova/plugin_list already defined
I see cordova_plugins.js only being referenced in three places inside the Injecter.java files located in:
as:
InputStream ims = assetManager.open("www/cordova_plugins.js");
Do I need to remove one of these references? Or do you have any other ideas of what could be causing this error? Also, is this error going to slowdown my app at all? It seems to only happen on the initial load. It looks like a simple throw error while checking if it already exist. This is the error code it's falling into:
define = function (id, factory) {
if (Object.prototype.hasOwnProperty.call(modules, id)) {
throw new Error('module ' + id + ' already defined');
}
modules[id] = {
id: id,
factory: factory
};
};
Thanks for any help! And let me know if you need any additional information to make more sense of the question!
I was able to find 2 different places that are calling functions on cordova_plugins. I commented out these functions from the phonegap/plugins Injecter and it seemed to get rid of all the errors.
Injecter.getInstance().injectJavascriptFile("www/cordova");
Injecter.getInstance().injectJavascriptFile("www/cordova_plugins");
Injecter.getInstance().parseCordovaPlugins();
Injecter.getInstance().injectJavascriptFile("www/js/index");
Maybe it somehow was installed into 2 different locations but didn't need to be? Not sure if this is something anyone else will run into, but just incase.