Adding Crosswalk breaks SQLite plugin

Hi guys,

As the title states, after adding crosswalk, the SQLite plugin errors out,

Error: Could not open database
    at newSQLError (SQLitePlugin.js:25)
    at SQLitePlugin.js:194
    at Object.cordova.callbackFromNative (cordova.js:288)
    at processMessage (cordova.js:1079)
    at processMessages (cordova.js:1102)
cordova.js:305 Error in Error callbackId: SQLitePlugin1197703998 : TypeError: undefined is not a function

when trying to open the database like so,

window.sqlitePlugin.openDatabase({ name: 'myMobile.db' });

My cordova version: 4.3.0
My cordova-android version: 4.0.0-dev

I am assuming this is because Crosswalk requires cordova-android version >= 4.0. Has anyone else come across this, or have any ideas on how I can solve this?

I’ve also opened up an issue on the plugin’s github page, here.

Thanks!

I was able to recreate the problem on another machine, when creating a brand new Ionic project, my steps are as follows,

ionic start testApp tabs
cd testApp
ionic platform add android
cordova plugin add https://github.com/brodysoft/Cordova-SQLitePlugin.git

I then altered the www/js/app.js file, and added,

$ionicPlatform.ready(function() {
    var db = window.sqlitePlugin.openDatabase({name: "my.db"});
});

and ran ionic run android --device, at this point it works, and I am able to open the DB without any issues, but as soon as I add crosswalk, something goes awry,

ionic browser add crosswalk
ionic run android --device

which produces the before mentioned error, and the below output from adb logcat,

D/AndroidChromeClient(18693): file:///android_asset/www/plugins/com.brodysoft.sqlitePlugin/www/SQLitePlugin.js: Line 171 : OPEN database: my.db
I/chromium(18693): [INFO:CONSOLE(171)] "OPEN database: my.db", source: file:///android_asset/www/plugins/com.brodysoft.sqlitePlugin/www/SQLitePlugin.js (171)
E/SQLitePlugin(18693): unexpected error, stopping db thread
E/SQLitePlugin(18693): com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: Couldn't load sqlite4java-android-armv7l from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.ionicframework.awsmapp346623-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.ionicframework.awsmapp346623-2, /vendor/lib, /system/lib]]]: findLibrary returned null
E/SQLitePlugin(18693): 	at com.almworks.sqlite4java.SQLite.loadLibrary(SQLite.java:97)
E/SQLitePlugin(18693): 	at com.almworks.sqlite4java.SQLiteConnection.open0(SQLiteConnection.java:1441)
E/SQLitePlugin(18693): 	at com.almworks.sqlite4java.SQLiteConnection.open(SQLiteConnection.java:282)
E/SQLitePlugin(18693): 	at org.pgsqlite.SQLitePlugin.openDatabase(SQLitePlugin.java:235)
E/SQLitePlugin(18693): 	at org.pgsqlite.SQLitePlugin.access$000(SQLitePlugin.java:37)
E/SQLitePlugin(18693): 	at org.pgsqlite.SQLitePlugin$DBRunner.run(SQLitePlugin.java:652)
E/SQLitePlugin(18693): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/SQLitePlugin(18693): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/SQLitePlugin(18693): 	at java.lang.Thread.run(Thread.java:841)
E/SQLitePlugin(18693): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load sqlite4java-android-armv7l from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.ionicframework.awsmapp346623-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.ionicframework.awsmapp346623-2, /vendor/lib, /system/lib]]]: findLibrary returned null
E/SQLitePlugin(18693): 	at java.lang.Runtime.loadLibrary(Runtime.java:358)
E/SQLitePlugin(18693): 	at java.lang.System.loadLibrary(System.java:526)
E/SQLitePlugin(18693): 	at com.almworks.sqlite4java.Internal.tryLoadFromSystemPath(Internal.java:352)
E/SQLitePlugin(18693): 	at com.almworks.sqlite4java.Internal.loadLibraryX(Internal.java:124)
E/SQLitePlugin(18693): 	at com.almworks.sqlite4java.SQLite.loadLibrary(SQLite.java:95)
E/SQLitePlugin(18693): 	... 8 more
D/AndroidChromeClient(18693): file:///android_asset/www/plugins/com.brodysoft.sqlitePlugin/www/SQLitePlugin.js: Line 192 : OPEN database: my.db failed, aborting any pending transactions
I/chromium(18693): [INFO:CONSOLE(192)] "OPEN database: my.db failed, aborting any pending transactions", source: file:///android_asset/www/plugins/com.brodysoft.sqlitePlugin/www/SQLitePlugin.js (192)
D/AndroidChromeClient(18693): file:///android_asset/www/plugins/com.brodysoft.sqlitePlugin/www/SQLitePlugin.js: Line 79 : Could not open database
I/chromium(18693): [INFO:CONSOLE(79)] "Could not open database", source: file:///android_asset/www/plugins/com.brodysoft.sqlitePlugin/www/SQLitePlugin.js (79)

Has anyone else run into this issue? Could someone please shed some light on this?

Thanks!

We have exactly the same issue here.
We use pouchdb and SQLite plugin. It doesn’t works anymore when we add crosswalk…
We have exactly the same error as Odyss3us

Hello,

I encounter the same issue on my side ! I use The PouchDB lib to connect to

io.litehelpers.cordova.sqlite 0.7.8-dev “Cordova sqlite storage plugin”
- Working without CrossWalk

io.litehelpers.cordova.sqlite 0.7.8-dev “Cordova sqlite storage plugin”
- NOT Working with CrossWalk

plugins/io.litehelpers.cordova.sqlite/www/SQLitePlugin.js:192
OPEN database: _pouch_MyDB failed, aborting any pending transactions

com.brodysoft.sqlitePlugin 1.0.3 “Brodysoft SQLitePlugin”
- Working with or without Crosswalk.
But I cannot reinstall it anymore… last versions of the plugin are on litehelpers.

with “./engine/cordova-crosswalk-engine-c0.6.2” in the package.json it’s working.
with “./engine/cordova-crosswalk-engine-c0.7.1” it’s not. => OPEN database: _pouch_MyDB failed, aborting any pending transactions

OK with last Cordova Cli 5.0.0

with “./engine/cordova-crosswalk-engine-c0.6.2” in the package.json it’s NOT working.

I’m Stuck

Check out this issue: https://github.com/litehelpers/Cordova-sqlite-storage/issues/242

Looks like the shared object for arm-v8 was not included until recently. However my problem still isn’t solved because when we compile for arm-v7, the resulting APK doesn’t include the arm-v8 shared object.

There’s no gradle build target for arm-v8. What I really want is to compile for ARM processors, both 32-bit and 64-bit alike.

In the end I’m going with the “androidDatabaseImplementation: 2” detailed here: https://github.com/litehelpers/Cordova-sqlite-storage#android-sqlite-implementation

That appears to use the Android-integrated SQLite engine, so avoids having to bundle native code. I never did find the arm-v8 build target.

1 Like

Sorry, how u solved this problem?, i have the same error LINK