Rajesh
Rajesh

Reputation: 3778

Cordova 3.5 deviceready event not fired after 5 seconds

I recently upgraded my cordova app from cordova v2.9 to v3.5.0. After adding plugins from command-line, I imported my app to eclipse so that I can test on an android device. But, when I run the app, I see below logcat message:

07-08 11:24:03.359: I/Web Console(1500): deviceready has not fired after 5 seconds. at file:///android_asset/www/cordova/cordova.js:1154

07-08 11:24:03.359: D/CordovaLog(1500): file:///android_asset/www/cordova/cordova.js: Line 1147 : Channel not fired: onFileSystemPathsReady

07-08 11:24:03.359: I/Web Console(1500): Channel not fired: onFileSystemPathsReady at file:///android_asset/www/cordova/cordova.js:1147

According to Cordova Device ready doc, I had to bind deviceready inside document.ready(). It did not fire. Also tried binding it outside document.ready() according to some answers on SO. Still no luck. Can someone help me out???

Device ready event binding

function cordovaInit() {
    document.addEventListener('deviceready', initApp, false);
}

I call cordovaInit() from onload() of body element like below:

<body onload="cordovaInit()">

The deviceready issue is gone now, but I am getting a Nullpointer Exception as below:

07-08 18:58:40.750: W/System.err(6670): java.lang.NullPointerException
07-08 18:58:40.750: W/System.err(6670):     at org.apache.cordova.file.LocalFilesystem.filesystemPathForURL(LocalFilesystem.java:67)
07-08 18:58:40.750: W/System.err(6670):     at org.apache.cordova.file.LocalFilesystem.getFileForLocalURL(LocalFilesystem.java:189)
07-08 18:58:40.750: W/System.err(6670):     at org.apache.cordova.file.FileUtils.getFile(FileUtils.java:749)
07-08 18:58:40.760: W/System.err(6670):     at org.apache.cordova.file.FileUtils.access$5(FileUtils.java:742)
07-08 18:58:40.760: W/System.err(6670):     at org.apache.cordova.file.FileUtils$16.run(FileUtils.java:397)
07-08 18:58:40.760: W/System.err(6670):     at org.apache.cordova.file.FileUtils$23.run(FileUtils.java:525)
07-08 18:58:40.760: W/System.err(6670):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
07-08 18:58:40.760: W/System.err(6670):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
07-08 18:58:40.760: W/System.err(6670):     at java.lang.Thread.run(Thread.java:856)

Upvotes: 4

Views: 7745

Answers (4)

Eamonn Gahan
Eamonn Gahan

Reputation: 1978

Just wanted to add I encountered this issue today with cordova 4.0.0 I suspect this happens with more than just the File plugin because my problem was with Network information plugin (org.apache.cordova.network-information)

Back story: I had copied the project to a new folder and copied over the plugins/ directory (I knew not to copy platforms from a previous mistake). This made it so the app was loading in chrome correctly and building correctly but showing a white screen on my device. Debugging by going to chrome://inspect/#devices and looking at console logs I saw that it was because the device ready event was not firing after 5 seconds.

Fix: I removed the plugins with cordova plugin remove org.apache.cordova.network-information and re-added it with cordova plugin add org.apache.cordova.network-information

Upvotes: 0

Qvatra
Qvatra

Reputation: 3847

Did solve the same issue by uninstalling cordova.file plugin (and all plaugins that using it), uninstall platform, upgrade cordova to v4 and install all plugins back

Upvotes: 0

andmar8
andmar8

Reputation: 331

Something else I found, try adding a sdcard to your emulator

I found my initial error was the file plugin was not being allowed to access a file space, this was because it didn't exist in the emulator, I added an external card to the emulator definition and hey presto it worked

Upvotes: 0

Frix33
Frix33

Reputation: 1241

Same issue. Try to remove/update the File plugin, (org.apache.cordova.file) it's worked for me. OnFileSystemReady is an event of that plugin.

Upvotes: 2

Related Questions