Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Failed to run constructor: ReferenceError: PluginManager is not defined" in Android PhoneGap

How do I stop the Failed to run constructor: ReferenceError: PluginManager is not defined error in PhoneGap in Android?

like image 487
Tim Avatar asked Nov 28 '11 15:11

Tim


1 Answers

In version 1.0 of PhoneGap they changed the plugins mechanism.

The old way of adding plugins was in the PhoneGap.addConstructor part of the javascript file for the plugin.

You would have something like

PhoneGap.addConstructor(function() {
   PhoneGap.addPlugin('analytics', new Analytics());
   PluginManager.addService("GoogleAnalyticsTracker", "com.phonegap.plugins.analytics.GoogleAnalyticsTracker");
});

However in newer versions you now do the addService step inside the res/xml/plugins.xml file.

So in my case I was using the Google Analytics plugin which still uses the old method. It doesn't seem to do any harm being there as I think it just gets ignored. However, if you want to get rid of the error just comment out the PluginManager.addService(.....) line in your analytics.js file.

like image 170
Tim Avatar answered Dec 03 '22 15:12

Tim