dommer
dommer

Reputation: 19820

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.

Upvotes: 5

Views: 4864

Answers (2)

AzurGroup
AzurGroup

Reputation: 247

in my case it was because the

$(document).ready()...

function wasn't firing properly so i simply changed it to the javascript version

<body onload="init();">

in the html and defined a function

function init(){ 
     document.addEventListener("deviceready", onDeviceReady, true);
}

in my javascript file and it solved the problem

Upvotes: 0

Yogesh Agarwal
Yogesh Agarwal

Reputation: 2630

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.

Upvotes: 21

Related Questions