Start a new topic

E/SQLiteLog(11951): (1) statement aborts at 2: [VACUUM;] cannot VACUUM - SQL statements in progress

Hi guys,



I'm developing an app for iOS and Android. I'm using AngularJS / Ionic / Phonegap. Offline support is the most important feature for that app, but for some reason I get problems with certain Android devices.



I'm doing the init like the docs are saying:



$kinvey.init({

appKey : 'App Key',

appSecret : 'App Secret',

sync : {

enable : true,

online : navigator.onLine// The initial application state.

}

});



Online / offline sync works fine with iOS and Android 4.4.3 devices.

But when I start the $kinvey.User.login I get the following error via logcat:

**E/SQLiteLog(11951): (1) statement aborts at 2: [VACUUM;] cannot VACUUM - SQL statements in progress**



That's when the app stops working. I never get the login promise resolved or rejected.

I've tested it with Samsung Galaxy S4 Active on Android 4.2.2 and Samsung Galaxy Tab 2 on Android 4.1.2 .

Both with that error.



Now when I remove the sync part, it also works fine, just without offline capability. So clearly there is some issue with SQLite.

Any ideas?



Best Regards,



The SportThing

Anyone there who uses offline storage with an Android phonegap app? Does that work for you guys?
Are you using any other external libraries?



You might want to try uninstalling the app completely, and trying again. It could be that the apps local database somehow got corrupted.
I think this is the 3rd thread that is currently active in these forums with a 3 way combination of android, angular library, and sync enabled - and significant (app terminating) problems



Glad you got an error message though - as I never quite managed to catch that

**So, it took me a day to figure out what the problem is and how to solve it.**



I've downloaded the non minified angular kinvey library kinvey-angular-1.1.8.js.

After enabling DEBUG mode and adding a lot of own console.log commands I found out, that kinvey checks if WebSQL is available and then execute Database.use(WebSqlAdapter);

But after that they also check if IndexDB is available.



// Use IndexedDB adapter.

if('undefined' !== typeof IDBAdapter.impl && 'undefined' !== typeof root.sift) {

Database.use(IDBAdapter);



// Add `Kinvey.Query` operators not supported by `sift`.

['near', 'regex', 'within'].forEach(function(operator) {

root.sift.useOperator(operator, function() {

throw new Kinvey.Error(operator + ' query operator is not supported locally.');

});

});

}



IndexDB is only supported on Android 4.4+ but for some strange reason all the previous Android versions are raising their hand and saying "Yeah, I've got that!", when they actually don't.

Now there comes kinveys unfortunate code in play because typeof IDBAdapter.impl and typeof root.sift are both not undefined, so Database.use(IDBAdapter) gets executed and now kinvey is trying to use IndexDB on a system which actually doesn't support it.



**Here is the solution**

So either you mess with the kinvey code (better not) or you use that library here:

https://github.com/axemclion/IndexedDBShim



And that is how I include the files in my index.html





















Here are some tag lines for all the unfortunate souls who are battling with the same issue and searching this forum:

AngularJS / Ionic / Phonegap / Sync not working / Offline not working / Android 4 4.1 4.2 4.3 / IndexDB / WebSQL
Wow thanks sport thing! That fixed it



(I also had to ensure that not loaded when on IOS)
@"A B"‌ Thank you for referring me to this post, this has fixed my problem. @SportThing‌ Thank you for sharing your for the solution.
Thanks for digging into it. The problem is described [here](https://www.bountysource.com/issues/1371172-websql-not-selected-using-the-native-browser-using-newer-versions-of-android-confirmed-on-android-4-3) as well. As this is a device issue, I think the above solution is a good one. You might even want to do some user agent checking to only use the shim on Android
Login or Signup to post a comment