Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is cordova.exec() running in my Android PhoneGap (1.7) app before "deviceready"?

I'm trying to "PhoneGap" (1.7.0) a jQuery Mobile app (1.1.0) I have to create an Android app. However, I keep getting the following alert message.

ERROR: Attempting to call cordova.exec() before 'deviceready'. Ignoring.

It appears as if this may happen during $.ajax calls, but it difficult to be sure.

I'm not making any calls to Cordova functions in my app - it's pure JQM.

Any ideas what the problem is. Or, failing that, does anyone know why cordova.exec() might be called during an $.ajax request?

I'm running the app under Android 4.0.3, in a virtual device/simulator.

like image 333
dommer Avatar asked May 11 '12 20:05

dommer


1 Answers

I was having the similar issue after spending couple of hours i realized that cordova-1.7.0.js (or phonegap-1.7.0.js in your case) was of the iOS as originally i created project for iOS i replaced this file with the relevant android JS file and it started working.

The cordova-1.7.0.js is different for different mobile platforms, use the correct JS file for particular platform.

like image 88
Yogesh Agarwal Avatar answered Nov 05 '22 07:11

Yogesh Agarwal