2012-10-08 129 views
2

我對PhoneGap Android相對較新,我有一個iPhone應用程序,需要遷移到Android我已經從iPhone應用程序添加www到我的Android應用程序,並添加了清單的權限還有,甚至複製的XML文件夾config.xml和cordova.xml但問題是,我的設備功能齊全是沒有得到所謂的phonegap設備就緒功能不叫

這裏是我的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> 

這裏是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(''); 
     } 
    }; 

也看到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! 

回答

1

這是wher正在導致錯誤:

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 } 

系統無法找到一個意向,將通過調用deviceReady處理的數據顯示( )功能。這使我相信你可能在你的項目設置中有錯誤。

仔細檢查,如果你已經使用this guide

確保您已經逆轉,您可能需要您的安裝文件等whenmigrating代碼形式的ios到Android所做的任何iphone具體修改​​設置好一切。

3

您必須將www文件夾中的cordova.js更改爲android cordova.js

相關問題