SimpleJ
SimpleJ

Reputation: 14768

Cordova File plugin never becomes ready in Android

I have a dead simple Cordova app with a single plugin: org.apache.cordova.file.

When I emulate the app in an android emulator, the deviceready event is never fired, and I get this as an output:

D/CordovaLog( 1841): file:///android_asset/www/cordova.js: Line 1154 : deviceready has not fired after 5 seconds.
D/CordovaLog( 1841): file:///android_asset/www/cordova.js: Line 1147 : Channel not fired: onFileSystemPathsReady

Some additional information:

cordova --version
3.5.0-0.2.4

javac -version
javac 1.7.0_55

java -version
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1~deb7u1)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)

index.html:

<!doctype html>
<html>
    <head>
    </head>
    <body>

        <script src='cordova.js' type='text/javascript'></script>
        <script src='index.js' type='text/javascript'></script>
    </body>
</html>

index.js:

(function() {

    "use strict";

    document.addEventListener("deviceready", function() {
        console.log("Ready");
    }, false);

}());

Is the Cordova File plugin broken? Am I doing something wrong? Has anyone else come across this issue and found a solution?

Upvotes: 5

Views: 13850

Answers (4)

andreszs
andreszs

Reputation: 2956

I solved this by reverting to plugin version 7.0.0, then updating to 8.0.1 again normally.

Upvotes: 0

kapil
kapil

Reputation: 257

You need to include cordova plugin before closing of body tag , so that cordova gets loaded properly before body loading completes.


<!doctype html>
<html>
    <head>
    </head>
    <body>

        <script src='cordova.js' type='text/javascript'></script>
        <script src='index.js' type='text/javascript'></script>
    </body>
</html>

Upvotes: -1

brickpop
brickpop

Reputation: 2796

Try installing the 1.1.0 version of the file plugin. Updating to 1.2.0 was a bad idea.

cordova plugin add [email protected]

This made the job for me on Android (and on iOS I stopped having other exotic problems).

Upvotes: 6

jeff.d
jeff.d

Reputation: 429

I ran into the same issue.

What worked for me was using a different version of the File plugin found here: https://github.com/onflapp/cordova-plugin-file

Related topic: Android - Cordova 3.5.0 deviceready not firing after installing media plugin

Upvotes: 5

Related Questions