0

phonegap と localStorage を使用してアプリを作成しようとしていますが、iOS ではうまく動作しますが、Android では次のエラーが発生します:「sqlite が返されました: エラー コード = 14、msg = [42537b6056] の 27205 行目でファイルを開けません」 "。

私は答えを探しています(グーグルで検索してください:))が、成功していません。

コードとスタック トレースを以下に示します。

前もって感謝します。

            // Wait for Cordova to load
        document.addEventListener("deviceready", onDeviceReady, false);

        function onDeviceReady() {
            customers = {
                "data" : [
                    {
                        "name" : "Myself"
                    }
                ]
            }
            navigator.notification.alert(customers.data[0].name);
            window.localStorage.setItem("customers", JSON.stringify(customers));

            var retrievedCustomers = window.localStorage.getItem("customers");
            c = JSON.parse(retrievedCustomers);
            console.log(c);
            navigator.notification.alert(c.data[0].name);

        }

スタックトレース:

08-21 14:49:05.063: D/DroidGap(11816): DroidGap.onCreate()
08-21 14:49:05.223: D/CordovaWebView(11816): Origin to allow: http://127.0.0.1*
08-21 14:49:05.223: I/CordovaLog(11816): Found log level DEBUG
08-21 14:49:05.223: I/CordovaLog(11816): Changing log level to DEBUG(3)
08-21 14:49:05.223: I/CordovaLog(11816): Found preference for useBrowserHistory=false
08-21 14:49:05.223: D/CordovaLog(11816): Found preference for useBrowserHistory=false
08-21 14:49:05.233: D/DroidGap(11816): DroidGap.init()
08-21 14:49:05.253: D/CordovaWebView(11816): >>> loadUrl(file:///android_asset/www/index.html)
08-21 14:49:05.253: D/PluginManager(11816): init()
08-21 14:49:05.263: D/CordovaWebView(11816): >>> loadUrlNow()
08-21 14:49:05.273: D/SoftKeyboardDetect(11816): Ignore this event
08-21 14:49:05.303: D/SoftKeyboardDetect(11816): Ignore this event
08-21 14:49:05.353: D/SoftKeyboardDetect(11816): Ignore this event
08-21 14:49:05.413: D/DroidGap(11816): onMessage(onPageStarted,file:///android_asset/www/index.html)
08-21 14:49:05.463: D/szipinf(11816): Initializing inflate state
08-21 14:49:05.463: D/szipinf(11816): Initializing zlib to inflate
08-21 14:49:05.513: D/szipinf(11816): Initializing inflate state
08-21 14:49:05.513: D/szipinf(11816): Initializing inflate state
08-21 14:49:05.513: D/szipinf(11816): Initializing zlib to inflate
08-21 14:49:05.583: D/szipinf(11816): Initializing zlib to inflate
08-21 14:49:05.593: D/szipinf(11816): Initializing inflate state
08-21 14:49:05.603: D/szipinf(11816): Initializing zlib to inflate
08-21 14:49:05.813: D/dalvikvm(11816): GC_CONCURRENT freed 134K, 44% free 3390K/6023K, external 0K/0K, paused 4ms+9ms
08-21 14:49:09.143: D/Cordova(11816): onPageFinished(file:///android_asset/www/index.html)
08-21 14:49:09.143: D/CordovaWebView(11816): >>> loadUrlNow()
08-21 14:49:09.143: D/DroidGap(11816): onMessage(onNativeReady,null)
08-21 14:49:09.143: D/DroidGap(11816): onMessage(onPageFinished,file:///android_asset/www/index.html)
08-21 14:49:09.183: I/Database(11816): sqlite returned: error code = 14, msg = cannot open file at line 27205 of [42537b6056]
08-21 14:49:09.253: E/Cordova(11816): Error loading url gap://ready
08-21 14:49:09.253: E/Cordova(11816): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=gap://ready }
08-21 14:49:09.253: E/Cordova(11816):   at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
08-21 14:49:09.253: E/Cordova(11816):   at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
08-21 14:49:09.253: E/Cordova(11816):   at android.app.Activity.startActivityForResult(Activity.java:2827)
08-21 14:49:09.253: E/Cordova(11816):   at android.app.Activity.startActivity(Activity.java:2933)
08-21 14:49:09.253: E/Cordova(11816):   at org.apache.cordova.CordovaWebViewClient.shouldOverrideUrlLoading(CordovaWebViewClient.java:187)
08-21 14:49:09.253: E/Cordova(11816):   at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:216)
08-21 14:49:09.253: E/Cordova(11816):   at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:323)
08-21 14:49:09.253: E/Cordova(11816):   at android.os.Handler.dispatchMessage(Handler.java:99)
08-21 14:49:09.253: E/Cordova(11816):   at android.os.Looper.loop(Looper.java:130)
08-21 14:49:09.253: E/Cordova(11816):   at android.app.ActivityThread.main(ActivityThread.java:3835)
08-21 14:49:09.253: E/Cordova(11816):   at java.lang.reflect.Method.invokeNative(Native Method)
08-21 14:49:09.253: E/Cordova(11816):   at java.lang.reflect.Method.invoke(Method.java:507)
08-21 14:49:09.253: E/Cordova(11816):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
08-21 14:49:09.253: E/Cordova(11816):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
08-21 14:49:09.253: E/Cordova(11816):   at dalvik.system.NativeStart.main(Native Method)
08-21 14:49:11.153: D/DroidGap(11816): onMessage(spinner,stop)
08-21 14:49:14.316: D/CordovaWebView(11816): KeyDown has been triggered on the view
08-21 14:49:14.323: D/CordovaWebView(11816): >>> loadUrlNow()
08-21 14:49:14.783: D/DroidGap(11816): onDestroy()
08-21 14:49:14.783: D/CordovaWebView(11816): >>> loadUrlNow()
08-21 14:49:14.783: D/CordovaWebView(11816): >>> loadUrlNow()
08-21 14:49:14.803: D/DroidGap(11816): onMessage(onPageStarted,about:blank)
08-21 14:49:14.863: D/Cordova(11816): onPageFinished(about:blank)
08-21 14:49:14.863: D/DroidGap(11816): onMessage(onPageFinished,about:blank)
08-21 14:49:14.863: D/DroidGap(11816): onMessage(exit,null)
08-21 14:49:19.843: D/dalvikvm(11816): GC_EXPLICIT freed 350K, 49% free 3118K/6023K, external 0K/0K, paused 61ms
4

1 に答える 1

1

あなたが投稿したコードはうまく見えます。最近、localstorage オプションを使用して phonegap アプリを作成しました。唯一の違いは、localStorage.setItem代わりにwindow.localStorage.setItem.

エラー メッセージから、正確なエラーが何であるかを推測することはできません。JavaScript は、特にモバイル アプリではデバッグが難しい言語です。私にとって主に機能するアプローチは、コード行をコメントアウトし、アプリがいくつかの行なしで正常に動作するかどうかを確認することです (実際には逆に動作し、疑わしいすべてのコードを最初にコメントアウトし、アプリが動作していることを確認してから、コメントを外します。一度に 2 ~ 3 行、アプリがまだ機能しているかどうかを確認します)。正確な原因がわかれば、修正するのは簡単です。

于 2012-08-21T18:24:57.243 に答える