Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

copyDatabase in 2.0.0 #21

Closed
AtixD opened this issue May 18, 2016 · 20 comments
Closed

copyDatabase in 2.0.0 #21

AtixD opened this issue May 18, 2016 · 20 comments
Assignees

Comments

@AtixD
Copy link

AtixD commented May 18, 2016

In 2.0.0 sqlite.copyDatabase(dbname); -> file not found, in 1.7.1 working

@NathanaelA
Copy link
Owner

Are you having issues in iOS or android?

@AtixD
Copy link
Author

AtixD commented May 23, 2016

Android and iOS

@NathanaelA
Copy link
Owner

Hmm, I tested 2.01 on both iOS and Android with my sqlite example demo (which copies a database) and it worked fine for me. I even reset the iOS simulator so that no database files existed anymore.

Can you give me a sample app that doesn't work?

@AtixD
Copy link
Author

AtixD commented May 25, 2016

May 25 12:53:40 MacBook-Pro-Reuf HelloCanada[1780]: CONSOLE LOG file:///app/sql/sql.js:22:28: ReferenceError: Can't find variable: sqlite3_open_v2
May 25 12:53:40 MacBook-Pro-Reuf HelloCanada[1780]: 1   0x9f238 -[TNSRuntime executeModule:]
May 25 12:53:40 MacBook-Pro-Reuf HelloCanada[1780]: 2   0x500db main
May 25 12:53:40 MacBook-Pro-Reuf HelloCanada[1780]: 3   0x4a70a25 start
May 25 12:53:40 MacBook-Pro-Reuf HelloCanada[1780]: 4   0x1
May 25 12:53:40 MacBook-Pro-Reuf HelloCanada[1780]: file:///app/sql/sql.js:232:17: JS ERROR TypeError: null is not an object (evaluating 'dataBase.all')
May 25 12:53:40 MacBook-Pro-Reuf com.apple.CoreSimulator.SimDevice.5B75994F-E476-46D5-8AC9-AE896947D91B.launchd_sim[1309] (UIKitApplication:org.nativescript.Test[0xb920][1780]): Service exited due to signal: Segmentation fault: 11
    constructor() {        

        // sqlite.deleteDatabase(dbname);
        if (!sqlite.exists(dbname)) {
            sqlite.copyDatabase(dbname);
        }              

        new sqlite(dbname, function(err, dbConnection) {
            if (err) {
                console.log(err);
            }
            else
            {
                db =  dbConnection;
            }

        });

        this.db = db;
    }

@NathanaelA
Copy link
Owner

Well based on your error, I would venture you are potentially using an older version of sqlite actually.

I would try:

  1. tns plugin add nativescript-sqlite
  2. tns plugin add nativescript-sqlite

You also have a couple issues in your code; your code should be:

// This uses the sqlite library from the new install...
var sqlite = require('nativescript-sqlite');  

function constructor() {        
    // We need to copy "this" to some other variable to keep a reference to it inside the sql inner function (so we store it as self, to be used later).
    var self = this;

        // sqlite.deleteDatabase(dbname);
        if (!sqlite.exists(dbname)) {
            sqlite.copyDatabase(dbname);
        }              

        new sqlite(dbname, function(err, dbConnection) {
            if (err) {
                console.log(err);
            }
            else
            {
                // assign "this.db" to be our connection
                self.db =  dbConnection;
            }
        });

     // DO NOT assign this.db here; as you have a high likely hood of assigning it null as the sqlite opening connection is ASYNC meaning it can run after your assignment line of code
    }

@AtixD
Copy link
Author

AtixD commented May 25, 2016

I found the problem. While developing a project and if a folder have a "space" there is a mistake which I described above. Thank you for your response.

@handlebarcreative
Copy link

I'm also having a similar Can't find variable: sqlite3_open_v2 error.

  • I'm using SQLite version 3.8.10.2 2015-05-20 18:17:19
  • I installed with tns plugin add nativescript-sqlite. I'm using verision 1.0.8.
  • TNS is version 2.0.1.

My code is super simple, just


var sqlite = require("nativescript-sqlite");
var db;

new sqlite("test.db", function(err, dbConnection) {
    if (err) {
        console.log(err);
        return;
    }
    db = dbConnection;
});

@NathanaelA - Any thoughts?

@NathanaelA
Copy link
Owner

Yes, actually I do. Can you type "pod --version" and tell me which version you are using?

@handlebarcreative
Copy link

@NathanaelA - 'pov --version' shows 1.0.1

@NathanaelA
Copy link
Owner

NathanaelA commented Jun 11, 2016

Interesting same issue, I had this same issue occur with a friend of mine this week. The solution was to downgrade cocoapods to v0.39 and install xcproj.

gem uninstall cocoapods
gem uninstall cocoapods-core

gem install cocoapods -v 0.39.0
gem install cocoapods-core -v 0.39.0
brew install xcproj

Then you need to reinstall the ios platform so do a:
tns platform remove ios
tns platform add ios

And you should be good to go...

@handlebarcreative
Copy link

@NathanaelA - Thanks, but no luck with the suggestion above.

@NathanaelA
Copy link
Owner

@handlebarcreative Sorry I didn't see your response. Github didn't send me a email. Have you got this fixed?

If not,

  1. You are sure you followed all those steps?
  2. What error are you seeing?

@NathanaelA NathanaelA self-assigned this Jun 23, 2016
@DewaldDeJager
Copy link

DewaldDeJager commented Jul 4, 2016

I'm having similar issues, but so far only on one device. I've tested on a Genymotion emulator where it works fine, a CAT S40 (Android 5.1 - API Level 22) where the application crashes whenever a connection is opened (I have made improvements and will test again when I have access to the device) and a Vodafone Smart Tab 3G running Android 4.4.2 (API Level 19) where the copying doesn't seem to work. Further details about the third device follows:

The application runs and I have a few outputs in the various bits of code. When the existence is checked:

if (!sqlite.exists(dbname)) {
            var result = sqlite.copyDatabase(dbname);
        }

It returns true and I see JS: Database copied successfully. in the console (I just check the return value, ie. result). I then proceed to open a connection to the database:

        console.log("Opening database...");
        new sqlite(dbname, function(err, dbConnection) {
            if (err) {
                console.log("DB connection failed!");
                console.log("DB connection error: " + err);
            }
            else {
                db = dbConnection;
                db.resultType(sqlite.RESULTSASOBJECT);
                console.log("Database opened.");
            }
        });

Which outputs:

JS: Opening database...
D/SQLiteDatabase(15328):    at com.tns.Runtime.callJSMethodNative(Native Method)
D/SQLiteDatabase(15328):    at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861)
D/SQLiteDatabase(15328):    at com.tns.Runtime.callJSMethodImpl(Runtime.java:726)
D/SQLiteDatabase(15328):    at com.tns.Runtime.callJSMethod(Runtime.java:712)
D/SQLiteDatabase(15328):    at com.tns.Runtime.callJSMethod(Runtime.java:693)
D/SQLiteDatabase(15328):    at com.tns.Runtime.callJSMethod(Runtime.java:683)
JS: Database opened.

In the emulator, just my two console logs show rather than the additional output above. Testing the connection with db.isOpen() returns true, but if I continue and try insert a record, it fails with the following error (Basically just saying the table doesn't exist):

Error: android.database.sqlite.SQLiteException: no such table: Records (code 1): , while compiling: INSERT INTO Records (recordID, fieldOne, fieldTwo, fieldThree, fieldFour, fieldFive) values (?, ?, ?, ?, ?, ?)
JS:     android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
JS:     android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:893)
JS:     android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:504)
JS:     android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
JS:     android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
JS:     android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
JS:     android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1697)
JS:     android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1678)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:726)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:712)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:693)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:683)
JS:     com.tns.gen.android.view.View_OnClickListener.onClick(View_OnClickListener.java:11)
JS:     android.view.View.performClick(View.java:4490)
JS:     android.view.View$PerformClick.run(View.java:18815)
JS:     android.os.Handler.handleCallback(Handler.java:808)
JS:     android.os.Handler.dispatchMessage(Handler.java:103)
JS:     android.os.Looper.loop(Looper.java:193)
JS:     android.app.ActivityThread.main(ActivityThread.java:5354)
JS:     java.lang.reflect.Method.invokeNative(Native Method)
JS:     java.lang.reflect.Method.invoke(Method.java:515)
JS:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
JS:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
JS:     dalvik.system.NativeStart.main(Native Method)
JS: The new record id is:  

The exact same build runs on the Genymotion Android 6.0.0 (API Level 23) emulator just fine. I am going to test another device a little later.

My setup details:
Node: v5.3.0
Nativescript CLI: 2.1.1
tns-core-modules: 2.1.0
nativescript-sqlite: 1.0.10

@jeffswitzer
Copy link

I'm also having an issue when calling Sqlite.copyDatabase.

downloadDatabase() {
  let appsFolder = fs.knownFolders.currentApp();
  let databaseName = "myDatabase.db";
  let filePath = fs.path.join(appsFolder.path, databaseName);
  if(!fs.File.exists(filePath)) {
    http.getFile("https://myserver/" + databaseName, filePath).then((result) => {
      Sqlite.copyDatabase(databaseName);
      (new Sqlite(databaseName)).then(db => this.db = db, error => console.log("OPEN DB ERROR", error));
      }, (error) => console.log("Error RETRIEVING DATABASE", error));
   }
}

The following error is thrown when calling the above function:

JS: EXCEPTION: Error: Uncaught (in promise): Error: java.io.FileNotFoundException: app/myDatabase.db
JS:     android.content.res.AssetManager.openAsset(Native Method)
JS:     android.content.res.AssetManager.open(AssetManager.java:313)
JS:     android.content.res.AssetManager.open(AssetManager.java:287)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:726)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:712)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:693)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:683)
JS:     com.tns.gen.org.nativescript.widgets.Async_CompleteCallback.onComplete(Async_CompleteCallback.java:12)
JS:     org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:336)
JS:     org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:253)
JS:     android.os.AsyncTask.finish(AsyncTask.java:636)
JS:     android.os.AsyncTask.access$500(AsyncTask.java:177)
JS:     android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)
...

In my case I don't package the db file in the app folder before deploying, but I download the file to the app directory before calling copyDatabase. I verified that the file exists in the app directory by running:

adb -d shell "run-as org.nativescript.myapp ls /data/data/org.nativescript.myapp/files/app"
app.component.html
app.component.js
app.component.js.map
app.component.ts
app.css
main.js
main.js.map
main.ts
myDatabase.db
package.json
shared
tns_modules

@NathanaelA
Copy link
Owner

@DewaldDeJager can you do a "adb logcat" to get the full log between the
JS: Opening database...

and

JS: Database opened.

@jeffswitzer -
I think you are also missing part of the log; it does appear to be possibly inside competed callback; but there is no callstack into the sqlite code. So a adb logcat would be helpful also.

Also as a diagnotistic test I would also add:
console.log("DB: ", databaseName, ", FilePath:", filePath, "Exists:", fs.File.exists(filePath));
After the http get, but before you try and open the sqlite database.

@jeffswitzer
Copy link

Hi Nathanael,

For the diagnostic console.log after the http.getFile, but before the Sqlite.copyDatabase I get:
JS: DB: nn_system2.db , FilePath: /data/data/org.nativescript.naturesnotebookmobile/files/app/nn_system2.db Exists: true
Note I've changed the database name and project name since my code post from yesterday, but it seems the file is really there.

And here is the output from adb logcat:

I/ActivityManager(  987): Activity reported stop, but no longer stopping: ActivityRecord{11f093ef u0 org.nativescript.naturesnotebookmobile/com.tns.NativeScriptActivity t5241}
I/LaunchCheckinHandler(  987): Displayed org.nativescript.naturesnotebookmobile/com.tns.NativeScriptActivity,cp,ca,11001
I/ActivityManager(  987): Displayed org.nativescript.naturesnotebookmobile/com.tns.NativeScriptActivity: +10s946ms (total +11s2ms)
D/skia    ( 8724): --- SkImageDecoder::Factory returned null
V/JS      ( 8724): DB:  nn_system2.db , FilePath: /data/data/org.nativescript.naturesnotebookmobile/files/app/nn_system2.db Exists: true
V/JS      ( 8724): EXCEPTION: Error: Uncaught (in promise): Error: java.io.FileNotFoundException: app/nn_system2.db
V/JS      ( 8724):     android.content.res.AssetManager.openAsset(Native Method)
V/JS      ( 8724):     android.content.res.AssetManager.open(AssetManager.java:313)
V/JS      ( 8724):     android.content.res.AssetManager.open(AssetManager.java:287)
V/JS      ( 8724):     com.tns.Runtime.callJSMethodNative(Native Method)
V/JS      ( 8724):     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861)
V/JS      ( 8724):     com.tns.Runtime.callJSMethodImpl(Runtime.java:726)
V/JS      ( 8724):     com.tns.Runtime.callJSMethod(Runtime.java:712)
V/JS      ( 8724):     com.tns.Runtime.callJSMethod(Runtime.java:693)
V/JS      ( 8724):     com.tns.Runtime.callJSMethod(Runtime.java:683)
V/JS      ( 8724):     com.tns.gen.org.nativescript.widgets.Async_CompleteCallback.onComplete(Async_CompleteCallback.java:12)
V/JS      ( 8724):     org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:336)
V/JS      ( 8724):     org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:253)
V/JS      ( 8724):     android.os.AsyncTask.finish(AsyncTask.java:636)
V/JS      ( 8724):     android.os.AsyncTask.access$500(AsyncTask.java:177)
V/JS      ( 8724):     android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)
V/JS      ( 8724):     android.os.Handler.dispatchMessage(Handler.java:102)
V/JS      ( 8724):     android.os.Looper.loop(Looper.java:135)
V/JS      ( 8724):     android.app.ActivityThread.main(ActivityThread.java:5343)
V/JS      ( 8724):     java.lang.reflect.Method.invoke(Native Method)
V/JS      ( 8724):     java.lang.reflect.Method.invoke(Method.java:372)
V/JS      ( 8724):     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
V/JS      ( 8724):     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
V/JS      ( 8724): STACKTRACE:
V/JS      ( 8724): Error: Uncaught (in promise): Error: java.io.FileNotFoundException: app/nn_system2.db
V/JS      ( 8724):     android.content.res.AssetManager.openAsset(Native Method)
V/JS      ( 8724):     android.content.res.AssetManager.open(AssetManager.java:313)
V/JS      ( 8724):     android.content.res.AssetManager.open(AssetManager.java:287)
V/JS      ( 8724):     com.tns.Runtime.callJSMethodNative(Native Method)
V/JS      ( 8724):     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861)
V/JS      ( 8724):     com.tns.Runtime.callJSMethodImpl(Runtime.java:726)
V/JS      ( 8724):     com.tns.Runtime.callJSMethod(Runtime.java:712)
V/JS      ( 8724):     com.tns.Runtime.callJSMethod(Runtime.java:693)
V/JS      ( 8724):     com.tns.Runtime.callJSMethod(Runtime.java:683)
V/JS      ( 8724):     com.tns.gen.org.nativescript.widgets.Async_CompleteCallback.onComplete(Async_CompleteCallback.java:12)
V/JS      ( 8724):     org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:336)
V/JS      ( 8724):     org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:253)
V/JS      ( 8724):     android.os.AsyncTask.finish(AsyncTask.java:636)
V/JS      ( 8724):     android.os.AsyncTask.access$500(AsyncTask.java:177)
V/JS      ( 8724):     android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)
V/JS      ( 8724):     android.os.Handler.dispatchMessage(Handler.java:102)
V/JS      ( 8724):     android.os.Looper.loop(Looper.java:135)
V/JS      ( 8724):     android.app.ActivityThread.main(ActivityThread.java:5343)
V/JS      ( 8724):     java.lang.reflect.Method.invoke(Native Method)
V/JS      ( 8724):     java.lang.reflect.Method.invoke(Method.java:372)
V/JS      ( 8724):     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
V/JS      ( 8724):     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
V/JS      ( 8724):     at resolvePromise (/data/data/org.nativescript.naturesnotebookmobile/files/app/tns_modules/zone.js/dist/zone-node.js:496:32)
V/JS      ( 8724):     at /data/data/org.nativescript.naturesnotebookmobile/files/app/tns_modules/zone.js/dist/zone-node.js:532:18
V/JS      ( 8724):     at ZoneDelegate.invokeTask (/data/data/org.nativescript.naturesnotebookmobile/files/app/tns_modules/zone.js/dist/zone-node.js:314:38)
V/JS      ( 8724):     at Object.NgZoneImpl.inner.inner.fork.onInvokeTask (/data/data/org.nativescript.naturesnotebookmobile/files/app/tns_modules/@angular/core/src/zone/ng_zone_impl.js:37:41)
V/JS      ( 8724):     at ZoneDelegate.invokeTask (/data/data/org.nativescript.naturesnotebookmobile/files/app/tns_modules/zone.js/dist/zone-node.js:313:43)
V/JS      ( 8724):     at Zone.runTask (/data/data/org.nativescript.naturesnotebookmobile/files/app/tns_modules/zone.js/dist/zone-node.js:214:48)
V/JS      ( 8724):     at drainMicroTaskQueue (/data/data/org.nativescript.naturesnotebookmobile/files/app/tns_modules/zone.js/dist/zone-node.js:432:36)
E/JS      ( 8724): Unhandled Promise rejection: java.io.FileNotFoundException: app/nn_system2.db
E/JS      ( 8724):     android.content.res.AssetManager.openAsset(Native Method)
E/JS      ( 8724):     android.content.res.AssetManager.open(AssetManager.java:313)
E/JS      ( 8724):     android.content.res.AssetManager.open(AssetManager.java:287)
E/JS      ( 8724):     com.tns.Runtime.callJSMethodNative(Native Method)
E/JS      ( 8724):     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861)
E/JS      ( 8724):     com.tns.Runtime.callJSMethodImpl(Runtime.java:726)
E/JS      ( 8724):     com.tns.Runtime.callJSMethod(Runtime.java:712)
E/JS      ( 8724):     com.tns.Runtime.callJSMethod(Runtime.java:693)
E/JS      ( 8724):     com.tns.Runtime.callJSMethod(Runtime.java:683)
E/JS      ( 8724):     com.tns.gen.org.nativescript.widgets.Async_CompleteCallback.onComplete(Async_CompleteCallback.java:12)
E/JS      ( 8724):     org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:336)
E/JS      ( 8724):     org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:253)
E/JS      ( 8724):     android.os.AsyncTask.finish(AsyncTask.java:636)
E/JS      ( 8724):     android.os.AsyncTask.access$500(AsyncTask.java:177)
E/JS      ( 8724):     android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)
E/JS      ( 8724):     android.os.Handler.dispatchMessage(Handler.java:102)
E/JS      ( 8724):     android.os.Looper.loop(Looper.java:135)
E/JS      ( 8724):     android.app.ActivityThread.main(ActivityThread.java:5343)
E/JS      ( 8724):     java.lang.reflect.Method.invoke(Native Method)
E/JS      ( 8724):     java.lang.reflect.Method.invoke(Method.java:372)
E/JS      ( 8724):     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
E/JS      ( 8724):     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700) ; Zone: angular ; Task: Promise.then ; Value: Error: java.io.FileNotFoundException: app/nn_system2.db
E/JS      ( 8724):     android.content.res.AssetManager.openAsset(Native Method)
E/JS      ( 8724):     android.content.res.AssetManager.open(AssetManager.java:313)
E/JS      ( 8724):     android.content.res.AssetManager.open(AssetManager.java:287)
E/JS      ( 8724):     com.tns.Runtime.callJSMethodNative(Native Method)
E/JS      ( 8724):     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861)
E/JS      ( 8724):     com.tns.Runtime.callJSMethodImpl(Runtime.java:726)
E/JS      ( 8724):     com.tns.Runtime.callJSMethod(Runtime.java:712)
E/JS      ( 8724):     com.tns.Runtime.callJSMethod(Runtime.java:693)
E/JS      ( 8724):     com.tns.Runtime.callJSMethod(Runtime.java:683)
E/JS      ( 8724):     com.tns.gen.org.nativescript.widgets.Async_CompleteCallback.onComplete(Async_CompleteCallback.java:12)
E/JS      ( 8724):     org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:336)
E/JS      ( 8724):     org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:253)
E/JS      ( 8724):     android.os.AsyncTask.finish(AsyncTask.java:636)
E/JS      ( 8724):     android.os.AsyncTask.access$500(AsyncTask.java:177)
E/JS      ( 8724):     android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)
E/JS      ( 8724):     android.os.Handler.dispatchMessage(Handler.java:102)
E/JS      ( 8724):     android.os.Looper.loop(Looper.java:135)
E/JS      ( 8724):     android.app.ActivityThread.main(ActivityThread.java:5343)
E/JS      ( 8724):     java.lang.reflect.Method.invoke(Native Method)
E/JS      ( 8724):     java.lang.reflect.Method.invoke(Method.java:372)
E/JS      ( 8724):     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
E/JS      ( 8724):     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
E/JS      ( 8724): Error: Uncaught (in promise): Error: java.io.FileNotFoundException: app/nn_system2.db
E/JS      ( 8724):     android.content.res.AssetManager.openAsset(Native Method)
E/JS      ( 8724):     android.content.res.AssetManager.open(AssetManager.java:313)
E/JS      ( 8724):     android.content.res.AssetManager.open(AssetManager.java:287)
E/JS      ( 8724):     com.tns.Runtime.callJSMethodNative(Native Method)
E/JS      ( 8724):     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861)
E/JS      ( 8724):     com.tns.Runtime.callJSMethodImpl(Runtime.java:726)
E/JS      ( 8724):     com.tns.Runtime.callJSMethod(Runtime.java:712)
E/JS      ( 8724):     com.tns.Runtime.callJSMethod(Runtime.java:693)
E/JS      ( 8724):     com.tns.Runtime.callJSMethod(Runtime.java:683)
E/JS      ( 8724):     com.tns.gen.org.nativescript.widgets.Async_CompleteCallback.onComplete(Async_CompleteCallback.java:12)
E/JS      ( 8724):     org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:336)
E/JS      ( 8724):     org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:253)
E/JS      ( 8724):     android.os.AsyncTask.finish(AsyncTask.java:636)
E/JS      ( 8724):     android.os.AsyncTask.access$500(AsyncTask.java:177)
E/JS      ( 8724):     android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)
E/JS      ( 8724):     android.os.Handler.dispatchMessage(Handler.java:102)
E/JS      ( 8724):     android.os.Looper.loop(Looper.java:135)
E/JS      ( 8724):     android.app.ActivityThread.main(ActivityThread.java:5343)
E/JS      ( 8724):     java.lang.reflect.Method.invoke(Native Method)
E/JS      ( 8724):     java.lang.reflect.Method.invoke(Method.java:372)
E/JS      ( 8724):     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
E/JS      ( 8724):     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
I/Auth    ( 2404): [AuthDelegateWrapper] Service intent: Intent { 

@DewaldDeJager
Copy link

DewaldDeJager commented Jul 8, 2016

@NathanaelA: Thanks, that's a pretty helpful command! Here are the important snippet parts of the log:

V/JS      (23467): Opening database...
E/SQLiteLog(23467): (1) near "WITHOUT": syntax error
E/SQLiteLog(23467): (11) database corruption at line 93729 of [00bb9c9ce4]
E/SQLiteLog(23467): (1) near "WITHOUT": syntax error
E/SQLiteLog(23467): (11) database corruption at line 93729 of [00bb9c9ce4]
E/SQLiteLog(23467): (1) near "WITHOUT": syntax error
E/SQLiteLog(23467): (11) database corruption at line 93729 of [00bb9c9ce4]
E/SQLiteLog(23467): (11) malformed database schema (Sales) - near "WITHOUT": syntax error
E/DefaultDatabaseErrorHandler(23467): Corruption reported by sqlite on database: /data/data/com.company.example/databases/appData.sqlite
E/DefaultDatabaseErrorHandler(23467): deleting the database file: /data/data/com.company.example/databases/appData.sqlite
D/SQLiteDatabase(23535): beginTransaction()
D/SQLiteDatabase(23535): endTransaction()
D/SQLiteDatabase(23467): Db file is deleted

The WITHOUT part is referring to the WITHOUT ROWID since I'm using a different PK. I created a few other tables in the database with the same options set (Same PK) and they don't seem to be giving any issues.

I've just tried deleting that table (I don't use it as of yet) and now it's giving me the same error but on another table using WITHOUT ROWID. Once again, this is only on this specific device. When I run the exact same build on the Genymotion emulator mentioned in my previous post, I get absolutely no additional output:

07-08 16:50:30.863  1802  1802 V JS      : Opening database...
07-08 16:50:30.892  1802  1802 V JS      : Database opened.

@NathanaelA
Copy link
Owner

@jeffswitzer - Any chance you can provide me a sample app that behaves this way; Dewald has managed to fix his issue so your the only one still broken...

@NathanaelA
Copy link
Owner

Since there is no more activity on this since July; I assume you figured out your issue...

@TitikshaDaga
Copy link

Is there a size limit on sqlite file when you copy it from pc to device using sqlite.copyDatabase()? I am able to copy a 5MB file but unable to copy a 303MB file. Below is the code snippet:
if(!sqlite.exists(dbname)) { alert("no db"); sqlite.copyDatabase(dbname); console.log("copying"); }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants