Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.UnsatisfiedLinkError in jsqlite.Database.internal_init in Android Spatialite

I'm new to developing for Android and using Spatialite and can't figure out why my app is crashing on a few devices because of this error:

java.lang.UnsatisfiedLinkError: No implementation found for void jsqlite.Database.internal_init() (tried Java_jsqlite_Database_internal_1init and Java_jsqlite_Database_internal_1init__) at jsqlite.Database.internal_init(Native Method) at jsqlite.Database.(Database.java:25)

This crash report is from a Nexus 5 (hammerhead) with Android 6.0 but it's been reported on Xoom with Android 4.1 and a few other unknown devices. I think it maybe be related to NDK versions as mentioned in these issues:

Adding ".so" library to my android studio project
Android NDK java.lang.UnsatisfiedLinkError: findLibrary returned null https://bitbucket.org/almworks/sqlite4java/issues/71/arm64-bit. (although this is for sqlite4java)

Other than that I'm also getting this error/warning (depending on the device): libjsqlite.so has text relocations. This is wasting memory and prevents security hardening. Please fix. Although it doesnt crash the app like the other error.

like image 565
Jisike Avatar asked Feb 07 '23 09:02

Jisike


2 Answers

I solved it by setting in the app built.gradle (or in the AndroidManifest.xml) this:

targetSdkVersion 21

And it works! I know that it isn't a good solution, it's a patch, but i works!

***UPDATE

If you can't change the target version to 21, you can do the following:

  • Download the source code from:https://github.com/geopaparazzi/geopaparazzi
  • Clean all references in your project to spatialite, .war file, and jndi libraries
  • Copy module geopaparazzispatialitelibrary and integrate in your project
  • Clean the code that you don't need from the module
  • Compile, and enjoy your project targeting version 23

It's a bit complex process, but it works.

Expecially thanks to andrea antonello, he help me to solve the problem, and do a great job with spatialite.

like image 156
RoberV Avatar answered Feb 15 '23 11:02

RoberV


In case this can help anyone with the same problem, I solved this by updating the jni libraries. To do this i downloaded this file:

https://github.com/geopaparazzi/libjsqlite-spatialite-android/blob/master/archive/20150616.libjsqlite.4.3.0.tar.bz2

from the geopaparazzi github repo which contains the latest version of the jni libraries as of now.

Replace the .so files in the spatialiteandroid library with the ones in the archive file.

You can find all versions of the library here: https://github.com/geopaparazzi/libjsqlite-spatialite-android/tree/master/archive:

like image 41
Hbibna Avatar answered Feb 15 '23 10:02

Hbibna