1

I am trying to use sqlite4java in my android project. the following screenshot shows my project's setup:

My Project setup

As you can see i have copied the jar-file into my libs folder and included it in the build path. I have also copied the docs and the src-file as per the docs for sqlite4java. The zip-file i downloaded also contains a library-file called libsqlite4java-android-i686.sothat i included in the libs directory. what i get when i try to run my project (it will compile without complaining) is the follwing error message:

03-04 07:37:13.251: W/System.err(2419): 
com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: 
java.lang.UnsatisfiedLinkError: Couldn't load sqlite4java-android-i686 
from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data
/app/de.redhouse24.android-2.apk"],nativeLibraryDirectories=[/data
/app-lib/de.redhouse24.android-2, /system/lib]]]: findLibrary returned 
null

As you can see the file sqlite4java-android-i686.socannot be found. Being wiley, i renamed the libsqlite4java-andriod-i686.so file to sqlite4java-android-i686.so, which is why my project structure shows that name for the file. TBH, i renamed it because i found the suggestion in this discussion:
https://code.google.com/p/sqlite4java/issues/detail?id=42

I also tried to include the so-file in the build path, but that just stopped my project from compiling.

My question: What do i need to do to use sqlite4java in my android project?

Im using a mac and eclipse with adt, if that makes any difference.

7
  • 2
    Why exactly are you using sqlite4java, when there's native sqlite support within android's framework? If there is no specific requirement, consider using android's implementation of sqlite. Commented Mar 4, 2015 at 16:43
  • @Mjoellnir - its a project requirement to be able to reuse existing code, unfortunately. Commented Mar 4, 2015 at 16:46
  • @DerGolem - i tried that, it doesnt work. also the getting started guide explicitly says to put the the zip-files and the library file in the same folder as the jar file Commented Mar 4, 2015 at 16:47
  • try adding the libraries to the build path. Check if that helps. Though android itself has SQLite Commented Mar 4, 2015 at 16:52
  • Put it under libs/x86/libsqlite4java.so -- don't forget to include modules for ARM when you go into production. Commented Mar 4, 2015 at 17:17

1 Answer 1

2

First of all, renaming the library will not help you. Do not rename the library, leave the name as it was.

Second, you only have the 686-lib there. If you intent to run your app on something other than an atom-based device, you will have to add the so-files for the other architectures as well. Each architecture's so-files resides in a sub-directory under the libs directory, like this:

libs/x86
libs/armeabi
libs/armeabi-v7a

Put your libsqlite4java-android-i686.so file there, and also possible other .so files it might need as a dependency, and it should work.

Including the sources and docs into the libs-folder somewhat eludes me. That will only bloat your final apk file, which should be avoided. Your users will be thankful.

Sign up to request clarification or add additional context in comments.

2 Comments

that was it! thank you. how did you know about the subfolders? i couldnt find anything about that on the entire internet...
Well, I am working a lot with NDK stuff. It's documented in the Android NDK, and when you create your own NDK libraries, you'll also see these folders being created by the NDK's build process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.