简体   繁体   中英

Android - Cordova 3.5.0 deviceready not firing after installing media plugin

This is interesting and weird issue.

First I created Cordova project locally . I'm not using Bd . using

cordova create test com.test.project.story "Test"

Which worked successfully!

Then I added android platform, using

cordova platform add android

Worked successfully.

Then I built the project using

cordova build

Worked, again.

I opened the project from Eclipse and ran it on emulator. Worked properly.

Then I thought of adding some plugins in my project using

cordova plugin add org.apache.cordova.file
cordova plugin add org.apache.cordova.media

Removed the android platform and added the platform again. Then built and ran the project on emulator.

The screen was stuck on Connecting to device forever.

I rechecked if I was using the correct cordova.js for android platform. It is correct, and it says

// Platform: android
// 3.5.0

Checked ADB log and there are a lot of suspicious things going on.

D/CordovaWebViewClient( 1581): onPageFinished(file:///android_asset/www/index.html)
D/CordovaActivity( 1581): onMessage(onPageFinished,file:///android_asset/www/index.html)
D/CordovaActivity( 1581): onMessage(spinner,stop)
D/TilesManager( 1581): new EGLContext from framework: 2a1a2a10 
D/GLWebViewState( 1581): Reinit shader
D/dalvikvm(  270): GC_CONCURRENT freed 322K, 46% free 9831K/17991K, paused 813ms+21ms, total 2252ms
D/dalvikvm(  270): WAIT_FOR_CONCURRENT_GC blocked 906ms
D/GLWebViewState( 1581): Reinit transferQueue
W/ApplicationContext( 1581): Unable to create external files directory
D/        ( 1581): HostConnection::get() New Host Connection established 0x4a5f8558, tid 1605
E/PluginManager( 1581): Uncaught exception from plugin
E/PluginManager( 1581): java.lang.NullPointerException
E/PluginManager( 1581):     at org.apache.cordova.file.FileUtils.requestAllPaths(FileUtils.java:866)
E/PluginManager( 1581):     at org.apache.cordova.file.FileUtils.execute(FileUtils.java:348)
E/PluginManager( 1581):     at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:65)
E/PluginManager( 1581):     at org.apache.cordova.PluginManager.execHelper(PluginManager.java:242)
E/PluginManager( 1581):     at org.apache.cordova.PluginManager.exec(PluginManager.java:227)
E/PluginManager( 1581):     at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:53)
E/PluginManager( 1581):     at org.apache.cordova.CordovaChromeClient.onJsPrompt(CordovaChromeClient.java:227)
E/PluginManager( 1581):     at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:655)
E/PluginManager( 1581):     at android.os.Handler.dispatchMessage(Handler.java:99)
E/PluginManager( 1581):     at android.os.Looper.loop(Looper.java:137)
E/PluginManager( 1581):     at android.app.ActivityThread.main(ActivityThread.java:4745)
E/PluginManager( 1581):     at java.lang.reflect.Method.invokeNative(Native Method)
E/PluginManager( 1581):     at java.lang.reflect.Method.invoke(Method.java:511)
E/PluginManager( 1581):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
E/PluginManager( 1581):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/PluginManager( 1581):     at dalvik.system.NativeStart.main(Native Method)
D/dalvikvm(  270): GC_FOR_ALLOC freed 593K, 48% free 9509K/17991K, paused 275ms, total 280ms
I/dalvikvm-heap(  270): Grow heap (frag case) to 10.559MB for 1286224-byte allocation
D/dalvikvm(  270): GC_FOR_ALLOC freed 2K, 41% free 10763K/17991K, paused 182ms, total 186ms
D/dalvikvm(  270): GC_CONCURRENT freed 61K, 38% free 11284K/17991K, paused 41ms+11ms, total 304ms
D/CordovaActivity( 1581): onMessage(spinner,stop)
D/dalvikvm(  270): GC_CONCURRENT freed 2676K, 43% free 10293K/17991K, paused 16ms+29ms, total 130ms
D/CordovaLog( 1581): file:///android_asset/www/cordova.js: Line 1154 : deviceready has not fired after 5 seconds.
I/Web Console( 1581): deviceready has not fired after 5 seconds. at file:///android_asset/www/cordova.js:1154
D/CordovaLog( 1581): file:///android_asset/www/cordova.js: Line 1147 : Channel not fired: onFileSystemPathsReady
I/Web Console( 1581): Channel not fired: onFileSystemPathsReady at file:///android_asset/www/cordova.js:1147
E/ThrottleService(  149): problem during onPollAlarm: java.lang.IllegalStateException: problem parsing stats: java.io.FileNotFoundException: /proc/net/xt_qtaguid/iface_stat_all: open failed: ENOENT (No such file or directory)
D/dalvikvm(  251): GC_CONCURRENT freed 384K, 9% free 6556K/7175K, paused 7ms+5ms, total 67ms
D/dalvikvm(  251): GC_CONCURRENT freed 384K, 9% free 6556K/7175K, paused 6ms+13ms, total 62ms
I/EventLogService(  240): Aggregate from 1403981475023 (log), 1403981475023 (data)
E/ThrottleService(  149): problem during onPollAlarm: java.lang.IllegalStateException: problem parsing stats: java.io.FileNotFoundException: /proc/net/xt_qtaguid/iface_stat_all: open failed: ENOENT (No such file or directory)

What's going on here?

UPDATE:

Works fine on iOS.

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: Cordova File plugin never becomes ready in Android

对我来说,它通过在index.html中添加cordova.js来解决(虽然它在ripple中不是必需的)

<script src="cordova.js"></script>

I ran into the same and resolved using apache official dev build File plugin:

Funny enough cordova release 1.3.1-dev is more stable then official release 1.2.0 ...

By now a newer version of the file plugin has been released. You should no longer experience the issue with the updated version (and there is thus no longer a need to downgrade).

I had a similar issue. deviceReady event was not firing (ionic app on android). Worked after I removed the file plugin v1.2 and then added v1.1 instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM