Tim
Tim

Reputation: 5767

"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?

Upvotes: 5

Views: 2392

Answers (1)

Tim
Tim

Reputation: 5767

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.

Upvotes: 8

Related Questions