I am trying to debug what the cordova_plugins.json file is used for?
I am using multiple plugins so far and I have never interacted with this file. I want to figure out why cordova makes an xhr request for this file at initialization.
When looking at my console I keep seeing this 404 error every time I test my app in Chrome and like to understand why this file is necessary.
It seems like a feature introduced in Cordova 2.6.0, at least I just noticed in this version.
At this point I could not find any documentation and I don't have many details on it, but right now I solved the 404 issue adding a dummy cordova_plugins.json file to the root of my project.
As it expects a valid json file I added the following content to the file: "just a dummy file required by Cordova 2.6.0"
It seems this is a know issue as discussed: here
Creating a dummy json file did not solved the problem for me... Indeed, remove this entire chunk of code at the end of cordova-2.7.0.js
// Try to XHR the cordova_plugins.json file asynchronously.
try { // we commented we were going to try, so let us actually try and catch
var xhr = new context.XMLHttpRequest();
xhr.onload = function() {
// If the response is a JSON string which composes an array, call handlePluginsObject.
// If the request fails, or the response is not a JSON array, just call finishPluginLoading.
var obj = this.responseText && JSON.parse(this.responseText);
if (obj && obj instanceof Array && obj.length > 0) {
handlePluginsObject(obj);
} else {
finishPluginLoading();
}
};
xhr.onerror = function() {
finishPluginLoading();
};
xhr.open('GET', 'cordova_plugins.json', true); // Async
xhr.send();
}
catch(err){
finishPluginLoading();
}
and replace it with a call to finishPluginLoading() will solve the problem.
Filip Maj of Adobe has said elsewhere that this is due to (so far) partially implemented plugin tooling. In future versions of Cordova, the plugin tooling will generate cordova_plugins.json itself.
For now, he has said it's save to completely ignore the 404 error. If you feel it is affecting your application, you should file a bug with Cordova.
[Note that if you add a dummy file yourself, it may affect the integration of Plugins]
i confirm francis answer and would note that on 2.7 if a dummy file is inserted, sometimes it starts an infinite loop on error "processMessage failed: invalid message:" (line cordova-2.7.0.js:971). keeping the 404 error seems indeed safer. (ref: https://groups.google.com/forum/?fromgroups#!topic/phonegap/slbvvtEw0aw)
That file did represent a bug/loose end in previous versions of Cordova/PhoneGap - and nurieta's suggested fix did resolve the (harmless) error thrown in its absence. The successor to this file is now created and handled by the Cordova/PhoneGap CLI entirely and resides in /myapp/platforms/#platform#/www/cordova_plugins.js
Bottom line - though the file sorta exists still this is no longer an issue as of Cordova 3.0.
I actually mock this file as an empty json file whose content is : "{}" and -using cordova 2.6- that seems to fix issues. There was not an ugly 404 and cordova seemed to work fine.
Edit: You can delete the code that does the ajax request all together from cordova and things would work just fine.
You can find out more about it here.
The location in the SDK / XDK is like: xdk-new\xdk\components\server\emulator\resources\cordova_plugins.json
Are you using Sencha Touch?
You can ignore the error but if you want to package the app for iOS you wont be able to. I solved the issue by going back to cordova-2.5.0.js.