storesafe / cordova-sqlite-storage

A Cordova/PhoneGap plugin to open and use sqlite databases on Android, iOS and Windows with HTML5/Web SQL API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash with Crosswalk on x86 64bit

enricodeleo opened this issue · comments

As other users pointed out already this plugin causes a crash on 64 bit architectures if run under Crosswalk (tested on various versions, canary included).

This plugin also caused the apk to be generated as multi architecture instead of per architecture.

With the very same environment, switching just back to com.brodysoft.sqlitePlugin 1.0.4 resolved these issues.
The problem is definitely something that is on 0.7.x. Hope this feedback helps.

The workaround is to include androidDatabaseImplementation: 2 in your window.sqlitePlugin.openDatabase options. This will be documented in README.md.

And thanks for the feedback!

@brodybits thank you, I already tried androidDatabaseImplementation: 2 but it crashes anyway on my Samsung Galaxy s6 Edge with Android 5.1.1

Can you paste the crash log?

Also, IIRC there are two ways to use Crosswalk: either use Crosswalk to create your Cordova project or add Crosswalk as a plugin. It helped some people earlier this year to add Crosswalk as a plugin.

I found that 0.7.10 always crashes when used with Crosswalk (I'm using Crosswalk as a plugin). With 0.7.7, it works fine, but only if you use androidDatabaseImplementation: 2.

Try removing sqlite-native-driver.jar from your libs directory, it has caused problems for others. Then you have to use androidDatabaseImplementation: 2.

Thanks @brodybits. That did the trick. BTW, @enricodeleo, I tried this on Samsung Galaxy S6 Edge (via Testdroid), and it worked fine for me.

@hanthomas I tried on a physical device. With the former configuration (latest version of crosswalk as plugin and cordova-sqlite-storage to 0.7.10) I got an error in /lib. Extracting the apk with unzip I find a unique file per architecture that is libsqlc-native-driver.so. Don't know if this information gives any help...

sqlite-native-driver.jar comes with the unique file per architecture in /lib, since it worked for me when I tested on my own device. It has caused problems and I will get rid of that JAR very soon. Please remove it from your libs if you are using Crosswalk.

@enricodeleo Here's what I did:

  1. Removed reference to sqlite-native-driver.jar from plugins/io.litehelpers.cordova.sqlite/plugin.xml
  2. Deleted plugins/io.litehelpers.cordova.sqlite/src/android/libs/sqlite-native-driver.jar file
  3. Deleted platforms/android/libs/sqlite-native-driver.jar file.

This removed any reference or copy of the JAR that's been causing problems. Then, I built the app, which then worked properly on all my Android devices (at least the ones I possess and those that I have access to in Testdroid).

I just updated the project to distribute the native Android library files individually. You may not have to include androidDatabaseImplementation: 2 in your openDatabase options anymore.

@brodybits Great! Thank you!

@brodybits Cool deal!

@brodybits the problem still exists if you build only one apk for all devices (ext.cdvBuildMultipleApks = null;). Is there any solution to make this work with only one build.apk?

@EpoX44 can you do me a favor and run the tree command (or otherwise list the contents) of your Android project's libs?

./platforms/android/libs/
├── arm64-v8a
│   └── libsqlite4java-android-aarch64.so
├── armeabi
│   └── libsqlite4java-android-armv5tejl.so
├── armeabi-v7a
│   └── libsqlite4java-android-armv7l.so
├── sqlite4java.jar
├── x86
│   └── libsqlite4java-android-i686.so
└── x86_64
└── libsqlite4java-android-x86_64.so

This is in the libs folder.

Hmm, it does not show me the native libraries from Crosswalk. It was reported that you will have better luck using the cordova-crosswalk plugin instead of the Crosswalk-cordova project.

I use the cordova-crosswalk-webview plugin from https://github.com/crosswalk-project/cordova-plugin-crosswalk-webview

Also do you include androidDatabaseImplementation: 2 in your openDatabase options? It may still be necessary.

Yeah I include that.

I also have to say that the app doesn't crash directly. The problem is that if I open it I get the message that the Crosswalk Project Service is not found and that I have to download it from the Appstore. But I set the xwalkMode to embedded and the size of the app on the device shows me that it is embedded.
With the fixes in this thread the app starts as usual without any problems.
Only if I build one apk for all devices it doesn't work and the message appears again.

Is there no solution for my problem?

This is a major issue and should be given priority attention.

@EpoX44 @jpike88 @brodybits:
I've been having the same issue with sister plugin cordova-sqlite-evfree 0.8.2 and cordova-plugin-crosswalk-webview 1.5.0, and managed to fix the above issue by doing the following (into a single APK):

A. Removed from plugin.xml:

<source-file src="src/android/libs/x86_64/libsqlc-native-driver.so" target-dir="libs/x86_64"/>
<source-file src="src/android/libs/arm64-v8a/libsqlc-native-driver.so" target-dir="libs/arm64-v8a"/>

B. Added to my openDatabase calls in javascript:

androidDatabaseImplementation: 2

C. Deleted the folders platforms/android/libs/x86_64/ and platforms/android/libs/arm64-v8a/
D. Deleted the folder platforms/build/ to make sure it re-creates everything

I hope this helps, the 64 bit support in Crosswalk isn't quite there yet at the time of writing. It is in the plugin but only spits out EITHER a 32-bit variant or 64-bit variant. When it does both into one APK, the removed files above may need to be re-included.

Thanks @CookieCookson. I will publish a version without the native Android libs when I get a chance.

Also a gentle reminder that if you publish an app using the cordova-sqlite-evfree plugin you are obligated to either purchase a commercial license or offer the source code under the GPL.

The commercial license is available under the following options:

  • Use in a single app under the same license as Cordova-sqlite-storage and cordova-sqlite-ext for (US) $500 discounted to $300 until the end of June 2016
  • Use in unlimited apps by an individual developer or single company for (US) $3000 discounted to $1800 until the end of June 2016

Contact sales@litehelpers.net

Cool beans. Thanks for the heads up on the licence, turns out I only need to use cordova-sqlite-ext so won't be using it on a published app.

I found a workaround.

If you build it with all builds of arm32, arm64 and x86 crosswalk present, it will work fine.

This will be documented when I get a chance.

May be related to: #247

@brodybits - This is issue occurs even without Crosswalk. I have a Samsung Galaxy S6 edge device which crashed earlier but the workaround above given by @CookieCookson fixed it.
I am developing Application in Ionic 3.

From #752 (closing as a duplicate):

Hi guys,

I have the following problem when I start a new Cordova project and add crosswalk with the following parameters:

"cordova-plugin-crosswalk-webview": {
                "XWALK_MULTIPLEAPK": "false",
                "XWALK_VERSION": "23+",
                "XWALK_LITEVERSION": "xwalk_core_library_canary:17+",
                "XWALK_COMMANDLINE": "--disable-pull-to-refresh-effect",
                "XWALK_MODE": "embedded"
            },

and add the sqlite plugin and try to start the app on a x64 cpu device i get the following Message:
image

i hope someone can help

could be related to #336

https://github.com/danielehrhardt/sqlite-cordova-error

(I noticed the same question at crosswalk-project/cordova-plugin-crosswalk-webview#202)

Here is the recommended workaround:

  • remove reference to sqlite-native-driver.jar (JAR with NDK library objects) from plugin.xml as follows:
diff --git a/plugin.xml b/plugin.xml
index f813a4d..47f3719 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -35,8 +35,6 @@
 
         <!-- Android-sqlite-connector [jar]: -->
         <lib-file src="node_modules/cordova-sqlite-storage-dependencies/libs/sqlite-connector.jar" />
-        <!-- Android-sqlite-connector native driver [native libs in jar]: -->
-        <lib-file src="node_modules/cordova-sqlite-storage-dependencies/libs/sqlite-native-driver.jar" />
     </platform>
 
     <!-- iOS -->
  • as described above: include androidDatabaseImplementation: 2 in your window.sqlitePlugin.openDatabase options.

I will not promise when I will get a chance to investigate this one within the free support program due to my existing backlog. For high-priority support needs please contact sales@litehelpers.net for more information.

Thank you very much @brodybits for this workaround. 🎉
Will it have some negative effects if we not using this sqlite-native-driver.jar (JAR with NDK library objects)?

At the moment our application is up and running fine. 👍