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.
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.
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:
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:
来源:https://stackoverflow.com/questions/36274100/java-lang-unsatisfiedlinkerror-in-jsqlite-database-internal-init-in-android-spat