Reputation: 3587
I'm relatively new to PhoneGap Android, I've an iPhone application and need to migrate to Android one I've added www from iPhone application to my Android application and added the permissions to manifest as well and even copied the XML folder with config.xml and cordova.xml but the problem is that my device ready function is not getting called
Here is my code for index.html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<link
href="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.css"
rel="stylesheet" />
<script src="scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<link href="css/style.css" type="text/css" rel="stylesheet" />
<link href="css/index.css" type="text/css" rel="stylesheet" />
<script src="scripts/app.js" type="text/javascript"></script>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript"
src="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.js"></script>
<script src="scripts/gallery_handler.js" type="text/javascript"></script>
<script src="scripts/itpoverlay.js" type="text/javascript"></script>
<script src="scripts/sqlite.js" type="text/javascript"></script>
<script src="scripts/jquery.exif.js" type="text/javascript"></script>
</head>
<body id="body">
<div class="app" style="display: none;">
<div id="deviceready">
<p class="status pending blink">Connecting to Device</p>
<p class="status complete blink hide">Device is Ready</p>
</div>
</div>
<div data-role="page" id="gallerypage" data-theme="a">
<div data-role="header">
<h1 class="headtitle">NG DESIIGNS</h1>
</div>
<div data-role="content" id="pagecontent">
<ul id="gallery" class="gallery">
</ul>
</div>
</div>
<script type="text/javascript" src="cordova-2.0.0.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
alert("app to be initialized");
app.initialize();
document.addEventListener('deviceready', function() {
alert("device ready called");
db.transaction(queryDB, errorCB, successCB);
}, false);
document.addEventListener("offline", function() {
alert("Your Device is offline");
}, false);
</script>
</body>
</html>
And here is index.js
var app = {
initialize: function() {
alert("index.js bind");
this.bind();
},
bind: function() {
alert("index.js bind function calld device ready");
document.addEventListener('deviceready', this.deviceready, false);
},
deviceready: function() {
alert("device ready");
// note that this is an event handler so the scope is that of the event
// so we need to call app.report(), and not this.report()
app.report('deviceready');
},
report: function(id) {
console.log("report:" + id);
// hide the .pending <p> and show the .complete <p>
document.querySelector('#' + id + ' .pending').className += ' hide';
var completeElem = document.querySelector('#' + id + ' .complete');
completeElem.className = completeElem.className.split('hide').join('');
}
};
Also see logcat
0-08 10:46:32.294: I/dalvikvm(763): threadid=3: reacting to signal 3
10-08 10:46:32.414: I/dalvikvm(763): Wrote stack traces to '/data/anr/traces.txt'
10-08 10:46:32.664: D/CordovaLog(763): Found preference for phonegap-version=2.0.0
10-08 10:46:32.673: D/CordovaLog(763): Found preference for orientation=default
10-08 10:46:32.673: D/CordovaLog(763): Found preference for target-device=universal
10-08 10:46:32.683: D/CordovaLog(763): Found preference for fullscreen=false
10-08 10:46:32.703: D/JsMessageQueue(763): Set native->JS mode to 1
10-08 10:46:32.803: I/dalvikvm(763): threadid=3: reacting to signal 3
10-08 10:46:32.873: I/dalvikvm(763): Wrote stack traces to '/data/anr/traces.txt'
10-08 10:46:32.934: W/webcore(763): java.lang.Throwable: EventHub.removeMessages(int what = 107) is not supported before the WebViewCore is set up.
10-08 10:46:32.934: W/webcore(763): at android.webkit.WebViewCore$EventHub.removeMessages(WebViewCore.java:1683)
10-08 10:46:32.934: W/webcore(763): at android.webkit.WebViewCore$EventHub.access$7900(WebViewCore.java:926)
10-08 10:46:32.934: W/webcore(763): at android.webkit.WebViewCore.removeMessages(WebViewCore.java:1795)
10-08 10:46:32.934: W/webcore(763): at android.webkit.WebView.sendOurVisibleRect(WebView.java:2917)
10-08 10:46:32.934: W/webcore(763): at android.webkit.ZoomManager.setZoomScale(ZoomManager.java:593)
10-08 10:46:32.934: W/webcore(763): at android.webkit.ZoomManager.access$1700(ZoomManager.java:49)
10-08 10:46:32.934: W/webcore(763): at android.webkit.ZoomManager$PostScale.run(ZoomManager.java:984)
10-08 10:46:32.934: W/webcore(763): at android.os.Handler.handleCallback(Handler.java:605)
10-08 10:46:32.934: W/webcore(763): at android.os.Handler.dispatchMessage(Handler.java:92)
10-08 10:46:32.934: W/webcore(763): at android.os.Looper.loop(Looper.java:137)
10-08 10:46:32.934: W/webcore(763): at android.app.ActivityThread.main(ActivityThread.java:4424)
10-08 10:46:32.934: W/webcore(763): at java.lang.reflect.Method.invokeNative(Native Method)
10-08 10:46:32.934: W/webcore(763): at java.lang.reflect.Method.invoke(Method.java:511)
10-08 10:46:32.934: W/webcore(763): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-08 10:46:32.934: W/webcore(763): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-08 10:46:32.934: W/webcore(763): at dalvik.system.NativeStart.main(Native Method)
10-08 10:46:32.964: D/gralloc_goldfish(763): Emulator without GPU emulation detected.
10-08 10:46:33.823: D/dalvikvm(763): GC_CONCURRENT freed 115K, 3% free 6838K/7047K, paused 4ms+4ms
10-08 10:46:41.603: I/SqliteDatabaseCpp(763): sqlite returned: error code = 14, msg = cannot open file at line 27701 of [8609a15dfa], db=/data/data/com.example.phonegapapp/databases/webview.db
10-08 10:46:41.603: I/SqliteDatabaseCpp(763): sqlite returned: error code = 14, msg = os_unix.c: open() at line 27701 - "" errno=2 path=/CachedGeoposition.db, db=/data/data/com.example.phonegapapp/databases/webview.db
10-08 10:46:41.994: E/Cordova(763): Error loading url gap://ready
10-08 10:46:41.994: E/Cordova(763): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=gap://ready }
10-08 10:46:41.994: E/Cordova(763): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512)
10-08 10:46:41.994: E/Cordova(763): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
10-08 10:46:41.994: E/Cordova(763): at android.app.Activity.startActivityForResult(Activity.java:3190)
10-08 10:46:41.994: E/Cordova(763): at android.app.Activity.startActivity(Activity.java:3297)
10-08 10:46:41.994: E/Cordova(763): at org.apache.cordova.CordovaWebViewClient.shouldOverrideUrlLoading(CordovaWebViewClient.java:222)
10-08 10:46:41.994: E/Cordova(763): at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:224)
10-08 10:46:41.994: E/Cordova(763): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:324)
10-08 10:46:41.994: E/Cordova(763): at android.os.Handler.dispatchMessage(Handler.java:99)
10-08 10:46:41.994: E/Cordova(763): at android.os.Looper.loop(Looper.java:137)
10-08 10:46:41.994: E/Cordova(763): at android.app.ActivityThread.main(ActivityThread.java:4424)
10-08 10:46:41.994: E/Cordova(763): at java.lang.reflect.Method.invokeNative(Native Method)
10-08 10:46:41.994: E/Cordova(763): at java.lang.reflect.Method.invoke(Method.java:511)
10-08 10:46:41.994: E/Cordova(763): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-08 10:46:41.994: E/Cordova(763): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-08 10:46:41.994: E/Cordova(763): at dalvik.system.NativeStart.main(Native Method)
10-08 10:46:43.553: E/libEGL(763): call to OpenGL ES API with no current context (logged once per thread)
10-08 10:46:43.553: D/ShaderProgram(763): couldn't load the vertex shader!
10-08 10:46:43.553: E/libEGL(763): call to OpenGL ES API with no current context (logged once per thread)
10-08 10:46:43.553: D/ShaderProgram(763): couldn't load the vertex shader!
10-08 10:46:43.553: E/libEGL(763): call to OpenGL ES API with no current context (logged once per thread)
10-08 10:46:43.553: D/ShaderProgram(763): couldn't load the vertex shader!
10-08 10:46:43.553: E/libEGL(763): call to OpenGL ES API with no current context (logged once per thread)
10-08 10:46:43.553: D/ShaderProgram(763): couldn't load the vertex shader!
10-08 10:46:43.553: E/libEGL(763): call to OpenGL ES API with no current context (logged once per thread)
10-08 10:46:43.553: D/ShaderProgram(763): couldn't load the vertex shader!
10-08 10:51:48.393: I/dalvikvm(828): threadid=3: reacting to signal 3
10-08 10:51:48.413: I/dalvikvm(828): Wrote stack traces to '/data/anr/traces.txt'
10-08 10:51:48.674: D/CordovaLog(828): Found preference for phonegap-version=2.0.0
10-08 10:51:48.694: D/CordovaLog(828): Found preference for orientation=default
10-08 10:51:48.694: D/CordovaLog(828): Found preference for target-device=universal
10-08 10:51:48.694: D/CordovaLog(828): Found preference for fullscreen=false
10-08 10:51:48.704: D/JsMessageQueue(828): Set native->JS mode to 1
10-08 10:51:48.893: I/dalvikvm(828): threadid=3: reacting to signal 3
10-08 10:51:48.934: W/webcore(828): java.lang.Throwable: EventHub.removeMessages(int what = 107) is not supported before the WebViewCore is set up.
10-08 10:51:48.934: W/webcore(828): at android.webkit.WebViewCore$EventHub.removeMessages(WebViewCore.java:1683)
10-08 10:51:48.934: W/webcore(828): at android.webkit.WebViewCore$EventHub.access$7900(WebViewCore.java:926)
10-08 10:51:48.934: W/webcore(828): at android.webkit.WebViewCore.removeMessages(WebViewCore.java:1795)
10-08 10:51:48.934: W/webcore(828): at android.webkit.WebView.sendOurVisibleRect(WebView.java:2917)
10-08 10:51:48.934: W/webcore(828): at android.webkit.ZoomManager.setZoomScale(ZoomManager.java:593)
10-08 10:51:48.934: W/webcore(828): at android.webkit.ZoomManager.access$1700(ZoomManager.java:49)
10-08 10:51:48.934: W/webcore(828): at android.webkit.ZoomManager$PostScale.run(ZoomManager.java:984)
10-08 10:51:48.934: W/webcore(828): at android.os.Handler.handleCallback(Handler.java:605)
10-08 10:51:48.934: W/webcore(828): at android.os.Handler.dispatchMessage(Handler.java:92)
10-08 10:51:48.934: W/webcore(828): at android.os.Looper.loop(Looper.java:137)
10-08 10:51:48.934: W/webcore(828): at android.app.ActivityThread.main(ActivityThread.java:4424)
10-08 10:51:48.934: W/webcore(828): at java.lang.reflect.Method.invokeNative(Native Method)
10-08 10:51:48.934: W/webcore(828): at java.lang.reflect.Method.invoke(Method.java:511)
10-08 10:51:48.934: W/webcore(828): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-08 10:51:48.934: W/webcore(828): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-08 10:51:48.934: W/webcore(828): at dalvik.system.NativeStart.main(Native Method)
10-08 10:51:48.954: D/gralloc_goldfish(828): Emulator without GPU emulation detected.
10-08 10:51:48.954: I/dalvikvm(828): Wrote stack traces to '/data/anr/traces.txt'
10-08 10:51:49.764: D/dalvikvm(828): GC_CONCURRENT freed 119K, 3% free 6839K/7047K, paused 4ms+3ms
10-08 10:52:10.864: I/SqliteDatabaseCpp(828): sqlite returned: error code = 14, msg = cannot open file at line 27701 of [8609a15dfa], db=/data/data/com.example.phonegapapp/databases/webview.db
10-08 10:52:10.874: I/SqliteDatabaseCpp(828): sqlite returned: error code = 14, msg = os_unix.c: open() at line 27701 - "" errno=2 path=/CachedGeoposition.db, db=/data/data/com.example.phonegapapp/databases/webview.db
10-08 10:52:11.233: E/Cordova(828): Error loading url gap://ready
10-08 10:52:11.233: E/Cordova(828): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=gap://ready }
10-08 10:52:11.233: E/Cordova(828): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512)
10-08 10:52:11.233: E/Cordova(828): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
10-08 10:52:11.233: E/Cordova(828): at android.app.Activity.startActivityForResult(Activity.java:3190)
10-08 10:52:11.233: E/Cordova(828): at android.app.Activity.startActivity(Activity.java:3297)
10-08 10:52:11.233: E/Cordova(828): at org.apache.cordova.CordovaWebViewClient.shouldOverrideUrlLoading(CordovaWebViewClient.java:222)
10-08 10:52:11.233: E/Cordova(828): at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:224)
10-08 10:52:11.233: E/Cordova(828): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:324)
10-08 10:52:11.233: E/Cordova(828): at android.os.Handler.dispatchMessage(Handler.java:99)
10-08 10:52:11.233: E/Cordova(828): at android.os.Looper.loop(Looper.java:137)
10-08 10:52:11.233: E/Cordova(828): at android.app.ActivityThread.main(ActivityThread.java:4424)
10-08 10:52:11.233: E/Cordova(828): at java.lang.reflect.Method.invokeNative(Native Method)
10-08 10:52:11.233: E/Cordova(828): at java.lang.reflect.Method.invoke(Method.java:511)
10-08 10:52:11.233: E/Cordova(828): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-08 10:52:11.233: E/Cordova(828): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-08 10:52:11.233: E/Cordova(828): at dalvik.system.NativeStart.main(Native Method)
10-08 10:52:12.824: E/libEGL(828): call to OpenGL ES API with no current context (logged once per thread)
10-08 10:52:12.824: D/ShaderProgram(828): couldn't load the vertex shader!
10-08 10:52:12.824: E/libEGL(828): call to OpenGL ES API with no current context (logged once per thread)
10-08 10:52:12.824: D/ShaderProgram(828): couldn't load the vertex shader!
10-08 10:52:12.824: E/libEGL(828): call to OpenGL ES API with no current context (logged once per thread)
10-08 10:52:12.824: D/ShaderProgram(828): couldn't load the vertex shader!
10-08 10:52:12.834: E/libEGL(828): call to OpenGL ES API with no current context (logged once per thread)
10-08 10:52:12.834: D/ShaderProgram(828): couldn't load the vertex shader!
10-08 10:52:12.834: E/libEGL(828): call to OpenGL ES API with no current context (logged once per thread)
10-08 10:52:12.834: D/ShaderProgram(828): couldn't load the vertex shader!
Upvotes: 2
Views: 7387
Reputation: 31
You have to change the cordova.js in your www folder to the one of android cordova.js
Upvotes: 3
Reputation: 20553
This is wher the error is being caused:
10-08 10:46:41.994: E/Cordova(763): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=gap://ready }
The system is not able to find an intent that will handle the display of data by calling the deviceReady() function. This leads me to beleive you might have an error in your project setup.
Double check if you have set everything up using this guide
Make sure you have reversed any iphone specific changes you might have made to your setup files etc whenmigrating your code form ios to android.
Upvotes: 1