Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cordovaRef.addConstructor is undefined in cordova 2.7 #9

Closed
breville opened this issue Jun 21, 2013 · 8 comments
Closed

cordovaRef.addConstructor is undefined in cordova 2.7 #9

breville opened this issue Jun 21, 2013 · 8 comments

Comments

@breville
Copy link

After upgrading a project to cordova 2.7, and also updating to latest GAPlugin, this runtime error occurs:

TypeError: 'undefined' is not a function (evaluating 'cordovaRef.addConstructor') at GAPlugin.js:56.

Is addConstructor now gone? Does GAPlugin need to be updated appropriately?

thanks

@bobeast
Copy link

bobeast commented Jun 21, 2013

Are you doing a local (manual) build, or are you using PhoneGap Build? Also is this on Android, or iOS?

@breville
Copy link
Author

This is a local manual build for iOS.

@breville
Copy link
Author

ETA on fix? Or should I roll back to Cordova 2.5?

@Trott
Copy link

Trott commented Jul 9, 2013

This StackOverflow answer seems to indicate that you can just remove the surrounding addConstructor() and just run the code in the constructor function directly. I haven't actually tried this, and I know very little about PhoneGap plugins. But if you want to give that a shot, I'd be interested in the results. I'm having issues using the plugin with PhoneGap 2.9.0 on PhoneGap Build and it certainly is reporting that there is no addConstructor(), so...

@zmillman
Copy link

I just solved this issue in my app by changing line 2 in GAPlugin.js like so:

// Reordered fallbacks to hopefully fix iOS compatibility
// var cordovaRef = window.PhoneGap || window.Cordova || window.cordova;
var cordovaRef = window.PhoneGap || window.cordova || window.Cordova;

Somehow, the window.Cordova variable was being set to a value that wasn't an actual usable object :|

@wmarbut
Copy link

wmarbut commented Sep 11, 2013

@zmillman This preliminarily seems to be resolving the issue for me as well. I'm running PhoneGap/Cordova 3.0 with a slightly modified java file, but the javascript was stock until the patch that you suggested.

@bobeast
Copy link

bobeast commented Oct 25, 2013

Fixed

@bobeast bobeast closed this as completed Oct 25, 2013
@aliokan
Copy link

aliokan commented Nov 11, 2013

I had the same issue with clean install Phonegap CLI 3.1 for Android to local build.
Il fixed them with zmillman change :

// var cordovaRef = window.PhoneGap || window.Cordova || window.cordova;
var cordovaRef = window.PhoneGap || window.cordova || window.Cordova;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants