Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the cordova_plugins.json file for? Cordova is requesting it at initialization

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.

like image 844
Eric H Avatar asked Apr 19 '13 01:04

Eric H


2 Answers

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"

like image 191
Felipe Plets Avatar answered Sep 17 '22 20:09

Felipe Plets


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.

like image 45
Etienne Desgagné Avatar answered Sep 20 '22 20:09

Etienne Desgagné