Unsatisfied Link error while using SQLCipher library
Asked Answered
C

3

7

I am using the SQLCipher Library for Android to Encrypt/Decrypt the DB file. I am following the exact steps that were discussed in the API to add the library.

But I am getting a Unsatisfied link error when i run the project... Here's the logcat...

11-15 13:12:08.482: ERROR/AndroidRuntime(340): java.lang.UnsatisfiedLinkError: dbopen
11-15 13:12:08.482: ERROR/AndroidRuntime(340):     at info.guardianproject.database.sqlcipher.SQLiteDatabase.dbopen(Native Method)
11-15 13:12:08.482: ERROR/AndroidRuntime(340):     at info.guardianproject.database.sqlcipher.SQLiteDatabase.<init>(SQLiteDatabase.java:1876)
11-15 13:12:08.482: ERROR/AndroidRuntime(340):     at info.guardianproject.database.sqlcipher.SQLiteDatabase.openDatabase(SQLiteDatabase.java:870)
11-15 13:12:08.482: ERROR/AndroidRuntime(340):     at info.guardianproject.database.sqlcipher.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:904)
11-15 13:12:08.482: ERROR/AndroidRuntime(340):     at info.guardianproject.database.sqlcipher.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:107)
11-15 13:12:08.482: ERROR/AndroidRuntime(340):     at com.myproject1.getInstance(AppData.java:60)

Please give me any reference or hint.

Cletacleti answered 15/11, 2011 at 13:0 Comment(0)
I
3

you need to add the .so files into the libs/armaebi folder of your eclipse project and rebuild.

Instrument answered 8/12, 2011 at 8:33 Comment(1)
What about if you've done that and still get the UnsatisfiedLinkError?Sericin
P
15

java.lang.UnsatisfiedLinkError happens when the SQLCipher library was not initialized before using.

To solve the problem, call SQLiteDatabase.loadLibs(this); before using.

For example:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SQLiteDatabase.loadLibs(this);

    // Set up the window layout
    setContentView(R.layout.main);

    //instance of database adapter
    db = DBAdapter.getInstance(this);

    //load database
    db.load("password goes here");
Pyrrolidine answered 30/4, 2012 at 15:3 Comment(0)
I
3

you need to add the .so files into the libs/armaebi folder of your eclipse project and rebuild.

Instrument answered 8/12, 2011 at 8:33 Comment(1)
What about if you've done that and still get the UnsatisfiedLinkError?Sericin
K
1

Could you share what version of SQLCipher for Android you are using? We have recently released a new version of SQLCipher for Android with many changes. If you are not currently up to date with the latest release you can get it here.

Kinross answered 15/11, 2011 at 15:15 Comment(4)
I've experienced this exception using SQLCipher v2.0 RC4. .so files are included in project...Gnarled
^ turns out it was yet another Eclipse bug causing this, whereby included libraries werent actually included.Gnarled
@Gnarled After following setfault's advice, I may have run into the same issue with sqlcipher v2.1.1. It can't find "libraryName "stlport_shared" (id=830025040304)". How did you get around this?Newsworthy
turns out the libraries have to be in folder "prj/libs" (plural) not "prj/lib"...what a horrible dependency.Newsworthy

© 2022 - 2024 — McMap. All rights reserved.