4

I am trying to add SQLCipher to my project. I am able to link the jar files to the project but there is problem linking the .so files provided.

Due to that I am getting UnSatisfiedLinkError when i try to open the DB.

Can anyone please let me know the best possible way to add .so files to the project and get it running.

Rahul Kalidindi
  • 4,666
  • 14
  • 56
  • 92

2 Answers2

5

In addition to jar files you need to include .so files. In my project I have:

jar files in project_root/libs/
.so files in project_root/libs/armeabi/

Also make sure that you have added the .jar files properly. Go to Project Properties -> Java Build Path -> Libraries tab make sure commonc-codec.jar, gueva-r09.jar, sqlcipher.jar are added there.

EDIT

1) Add a single sqlcipher.jar and a few .so’s to the application libs directory
2) Update the import path from android.database.sqlite.* to info.guardianproject.database.sqlite.* in any source files that reference it. The original android.database.Cursor can still be used unchanged.
3) Init the database in onCreate() and pass a variable argument to the open database method with a password*:

    SQLiteDatabase.loadLibs(this); //first init the db libraries with the context
    SQLiteOpenHelper.getWritableDatabase(“thisismysecret”):
Caner
  • 57,267
  • 35
  • 174
  • 180
  • You don't add .so files into the project. You need to just place them in a folder named `armeabi` in the same folder with jar files. Those jar files will load those .so files automatically when you call `SQLiteDatabase.loadLibs` from the code. – Caner Nov 18 '11 at 10:47
  • Done the same many time but i am still gettingjava.lang.UnsatisfiedLinkError: dbopen – Rahul Kalidindi Nov 18 '11 at 10:52
  • 1
    Make sure you call `SQLiteDatabase.loadLibs()` before you call `getWritableDatabase`. See my edit for details. – Caner Nov 18 '11 at 10:58
0

Can you use the adb shell command to verify what files are being deployed to your simulator after it has been unpacked. I have seen an issue where the .so files are not packaged up in the .apk file before, which is due to the IDE not pointing to the correct native library path for your application.

Nick Parker
  • 1,378
  • 1
  • 7
  • 10