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

PhoneGap.exec not defined error #1

Open
nomaam opened this issue May 25, 2012 · 7 comments
Open

PhoneGap.exec not defined error #1

nomaam opened this issue May 25, 2012 · 7 comments

Comments

@nomaam
Copy link

nomaam commented May 25, 2012

Hello,

I am using your plugin with phonegap and Cordova.

I followed your instructions and am getting an error with the .js file at line 4, PhoneGap.exec is not defined.

Could you please advise what the problem could be? Has this feature been depreciated in Cordova?

Thanks

@nomaam
Copy link
Author

nomaam commented May 26, 2012

I also tried changing this to Cordova.exec and same error.

@champierre
Copy link
Collaborator

The plugin should work with Cordova.

From the error message, I guess that probably you have not imported cordova.js.

Do you import cordova.js in your html by doing as follows?

<script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"></script>

@nomaam
Copy link
Author

nomaam commented May 28, 2012

Thank you for the reply.

Yes I have Cordova installed. I am using a fully functioning Cordova app. The app will not work once I install your plugin. I am also testing this directly onto a device, no virtual machine. Have you tested this new version in a development environment yet ? I spent hours trying to get this plugin to work with no success.

Perhaps you have a fully working demo?

Thank you.

@flinn
Copy link

flinn commented Jul 10, 2012

I am also having this issue both on a virtual android device and directly on a Galaxy Nexus that I am using to test my app. I am using cordova version 1.9.0 and I am importing it before the screen orientation plugin.

The error being reported is as follows...

07-10 18:30:24.118: E/Web Console(6437): Uncaught TypeError: Object # has no method 'exec' at file:///android_asset/www/pg-plugin-screen-orientation.js:4

@cannonerd
Copy link

The same error message appears for me also. The problem isn't the fact that I have misplaced files, because I can successfully deploy the landscape mode in for one on my views (the problem then being that every view after that is in landscape). So to fix this I tried to add for the next view portrait mode and ended up having a non working application with the mentioned error message.
08-09 12:44:02.300: D/CordovaLog(26237): file:///android_asset/www/lib/pg-plugin-screen-orientation.js: Line 4 : Uncaught TypeError: Object # has no method 'exec'

in the js file I tried both
cordova.exec(null, null, "ScreenOrientation", "set", [str]); and
PhoneGap.exec(success, fail, "ScreenOrientation", "set", [str]);
as possible solutions, but still crashing

@cannonerd
Copy link

Ha. Found a workaround.
The problem was that if the orientation change is fired too early, (for me the first view) it blows up the whole application. For me the fix was that I needed the landscape in a view that is deployed much later, so the fix was:

the view that needs to be landscape

    navigator.screenOrientation.set('landscape');
    window.weHaveChangedOrientation = true; 

and then in the first view

    if (window.weHaveChangedOrientation) {
      navigator.screenOrientation.set('portrait');
    }

so only force portrait if landscape has been forced earlier.

@cannonerd
Copy link

and remember to listen to the

document.addEventListener("deviceready", function(){
whatever
}, false);

to avoid problems I had :P

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

4 participants