Unable to run Android - DeviceReady in cordova -
i unable run android's device ready function (not getting fired). how fix it? have target sdk 22 , cordova 5.1.1 , android studio 1.0.1.
my index.html:
   <!doctype html> <html> <head>     <title>device ready example</title>     <script type="text/javascript" charset="utf-8" src="cordova.js"></script> </head> <body onload="onload()"> </body> </html> index.js:
 function onload() {     document.addeventlistener("deviceready", ondeviceready, false); }  // device apis available // function ondeviceready() {     window.addeventlistener("batterystatus", onbatterystatus, false); }  // handle batterystatus event // function onbatterystatus(info) {     console.log("level: " + info.level + " isplugged: " + info.isplugged); } and logged : console.log("level: " + info.level + " isplugged: " + info.isplugged);
if run on command propmpt: cordova build:
total time: 7.545 secs
 c:\users\salangar\hello\platforms\android\cordova\node_modules\q\q.js:126                 throw e;                       ^  error code 1 command: cmd args: /s /c  "c:\users\salangar\hello\platform s\android\gradlew cdvbuilddebug -b           c:\users\salangar\hello\platforms\android\build.gradle -dorg.gradle.daemon=true"  error building 1 of platforms: error: cmd: command failed exit code 1  may not have required environment or os build project error: cmd: command failed exit code 1    @ childprocess.whendone    (c:\users\salangar\appdata\roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:134:23)    @ childprocess.emit (events.js:110:17)    @ maybeclose (child_process.js:1015:16)    @ process.childprocess._handle.onexit (child_process.js:1087:5) logcat display:
i/webviewfactory﹕ loading com.android.webview version 39 (1737576-arm) (code 300001)   07-02 11:10:44.806    helloworld i/libraryloader﹕ time load native libraries: 726 ms (timestamps 7130-7856) 07-02 11:10:44.824    helloworld i/libraryloader﹕ expected native library version number "",actual native library version number "" 07-02 11:10:44.979    helloworld v/webviewchromiumfactoryprovider﹕ binding chromium main looper looper (main, tid 1) {951e68} 07-02 11:10:44.990    helloworld i/libraryloader﹕ expected native library version number "",actual native library version number ""   07-02 11:10:45.113    helloworld i/browserstartupcontroller﹕ initializing chromium process, singleprocess=true   07-02 11:10:45.021    helloworld i/chromium﹕ [info:library_loader_hooks.cc(104)] chromium logging enabled: level = 0, default verbosity = 0     07-02 11:10:45.140    helloworld w/art﹕ attempt remove local handle scope entry irt, ignoring 07-02 11:10:45.448    helloworld w/audiomanagerandroid﹕ requires bluetooth permission 07-02 11:10:45.575    helloworld w/chromium﹕ [warning:resource_bundle.cc(304)] locale_file_path.empty() 07-02 11:10:45.590    helloworld i/chromium﹕ [info:aw_browser_main_parts.cc(65)] load apk succesful, fd=31 off=46184 len=3037 07-02 11:10:45.614    helloworld i/chromium﹕ [info:aw_browser_main_parts.cc(78)] loading webviewchromium.pak from, fd:32 off:229484 len:1089587 07-02 11:10:45.828    helloworld e/chromium﹕ [error:gl_surface_egl.cc(165)] no suitable egl configs found. 07-02 11:10:45.829    helloworld e/chromium﹕ [error:gl_surface_android.cc(23)] glsurfaceegl::initializeoneoff failed. 07-02 11:10:45.835    helloworld e/chromium﹕ [error:browser_main_loop.cc(988)] glsurface::initializeoneoff failed 07-02 11:10:46.790    helloworld w/chromium﹕ [warning:data_reduction_proxy_settings.cc(331)] spdy proxy off @ startup 07-02 11:10:47.032    helloworld w/art﹕ attempt remove local handle scope entry irt, ignoring 07-02 11:10:47.115    helloworld w/awcontents﹕ ondetachedfromwindow called when detached. ignoring 07-02 11:10:47.328    helloworld d/systemwebviewengine﹕ cordovawebview running on device made by: unknown 07-02 11:10:47.408    helloworld w/art﹕ attempt remove local handle scope entry irt, ignoring 07-02 11:10:47.408    helloworld w/art﹕ attempt remove local handle scope entry irt, ignoring 07-02 11:10:47.712    helloworld i/art﹕ background sticky concurrent mark sweep gc freed 3517(255kb) allocspace objects, 2(32kb) los objects, 31% free, 764kb/1117kb, paused 2.313ms total 499.804ms 07-02 11:10:48.445    helloworld d/gralloc_goldfish﹕ emulator without gpu emulation detected. 07-02 11:10:55.758    helloworld d/jsmessagequeue﹕ set native->js mode onlineeventsbridgemode 07-02 11:10:56.152    helloworld i/art﹕ background partial concurrent mark sweep gc freed 3730(208kb) allocspace objects, 1(16kb) los objects, 53% free, 887kb/1911kb, paused 1.825ms total 326.232ms 07-02 11:10:57.749    helloworld i/choreographer﹕ skipped 45 frames!  application may doing work on main thread. 07-02 11:11:00.752    helloworld i/choreographer﹕ skipped 54 frames!  application may doing work on main thread. 07-02 11:11:01.075    helloworld i/choreographer﹕ skipped 31 frames!  application may doing work on main thread. 07-02 11:11:01.545    helloworld i/chromium﹕ [info:console(1188)] "deviceready has not fired after 5 seconds.", source: file:///android_asset/www/cordova.js (1188) 07-02 11:11:01.750    helloworld i/chromium﹕ [info:console(1181)] "channel not fired: onpluginsready", source: file:///android_asset/www/cordova.js (1181)  07-02 11:11:01.752    helloworld i/chromium﹕ [info:console(1181)] "channel not fired: oncordovaready", source: file:///android_asset/www/cordova.js (1181)   07-02 11:11:03.655    helloworld w/pluginmanager﹕ thread warning: exec() call coreandroid.show blocked main thread 161ms. plugin should use cordovainterface.getthreadpool(). 07-02 11:11:04.699    helloworld i/chromium﹕ [info:console(47)] "received event: deviceready", source: file:///android_asset/www/js/index.js (47)  07-02 11:11:27.708    helloworld i/choreographer﹕ skipped 33 frames!  application may doing work on main thread.  07-02 11:11:28.112    helloworld i/choreographer﹕ skipped 34 frames!  application may doing work on main thread. 07-02 11:11:58.646    helloworld i/choreographer﹕ skipped 33 frames!  application may doing work on main thread. 
- device ready function (not getting fired). how fix it?
you don't need use onload() function call deviceready event. instead of :-
function onload() { document.addeventlistener("deviceready", ondeviceready, false); } just write :- document.addeventlistener("deviceready", ondeviceready, false);
and thing need write script cordova.js part inside body tag , add index.js file cordova.js.
- where logged : console.log("level: " + info.level + " isplugged: " + info.isplugged);
this log print in logcat.
hope :) if have difficulties please let me know.
Comments
Post a Comment