UnsatisfiedLinkError when using libstlport_shared.so in project with SQLCipher

1.4k views Asked by At

I have an app which has a SQLite DB. I need to make this DB encrypted. I've looked at SqlCipher for Android as a solution and have looked at the following page.

SQLCipher

The following thread has a set up close to my original app. This has a class with an SqliteOpenHelper inner class.

SQLCipher openhelper example

I have copied the 3 jar files into my project's lib folder, as said in the 1st tutorial.

commons-codec.jar

guava-r09.jar

sqlcipher.jar

I have also copied the .so files into a folder at libs/armeabi

libdatabase_sqlcipher.so

libsqlcipher_android.so

libstlport_shared.so

I think the last libstlport_shared.so is causing problems and i have read somewhere that i must explicitly load it?

Below is my database class that creates a SQLCipher DB and tables.

import android.database.Cursor;
//import android.database.sqlite.SQLiteDatabase;
//import android.database.sqlite.SQLiteOpenHelper;
import net.sqlcipher.database.SQLiteDatabase;
import net.sqlcipher.database.SQLiteOpenHelper;

public class LoginValidate {

    private static final String TAG = LoginValidate.class.getSimpleName();

    // table transactions column names
    public static final String C_ID = BaseColumns._ID; // special for id
                                                        // internally in system
    public static final String C_TYPE = "type";
    public static final String C_COMPANY_ID = "companyid";
    public static final String C_PERSON_ID = "person";
    public static final String C_NAME = "name";
    public static final String C_TAG_ID = "tagid";
    public static final String C_STATUS = "status";
    public static final String C_TAG_SCAN_TIME = "tagscantime";
    public static final String C_TAG_SENTSERVER_TIME = "tagsentservertime";
    public static final String C_TRANSACTIONS_LATITUDE = "transactionslatitude";
    public static final String C_TRANSACTIONS_LONGITUDE = "transactionslongitude";
    public static final String C_DRIVER = "driver";



Context context;
    DBHelper dbhelper;
    NfcScannerApplication nfcscannerapplication;
    SharedPreferences appSharedPrefs;
    Editor prefsEditor;
    String versionName;

    public LoginValidate(Context context) {

        this.context = context;
        dbhelper = new DBHelper();
        nfcscannerapplication = (NfcScannerApplication) context
                .getApplicationContext();
        appSharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
        prefsEditor = appSharedPrefs.edit();



        SQLiteDatabase.loadLibs(context);

    }



public Cursor queryAllFromTransactions() {

        // open database
        SQLiteDatabase db = dbhelper.getReadableDatabase("12345");

        return db.query(DBHelper.TABLETRANSACTIONS, null, null, null, null,
                null, null);

    }


private class DBHelper extends SQLiteOpenHelper {

        // database name and version number
        public static final String DB_NAME = "carefreemobiledb.db";
        public static final int DB_VERSION = 55;

        // table names
        public static final String TABLETRANSACTIONS = "transactions";
        public static final String TABLECARER = "carer";
        public static final String TABLETRANSACTIONSMAP = "transactionsmap";
        public static final String TABLEPHONE = "phone";
        public static final String TABLECOMPANYID = "companyid";
        public static final String TABLEBACKGROUNDSERVICES = "backgroundservices";
        public static final String TABLEMESSAGE = "message";
        public static final String TABLEDUPLICATETRANSACTIONS = "tableduplicatetransactions";
        public static final String TABLECACHEDROTA = "tablecachedrota";
        public static final String TABLEUSERS = "users";
        public static final String TABLESTARTSTOPSHIFT = "startstopshift";
        public static final String TABLELOG = "log";

        public DBHelper() {
            super(context, DB_NAME, null, DB_VERSION);
        }

        @Override
        public void onCreate(SQLiteDatabase db) {



            Log.e(TAG, "SQLiteOpenHelper oncreate ");

            String sqlToCreateTransactionsTable = String
                    .format("create table %s ( %s INTEGER primary key, %s TEXT, %s TEXT, %s TEXT, %s TEXT, %s TEXT,"
                            + " %s TEXT, %s TEXT, %s INT, %s TEXT, %s TEXT, %s TEXT )",
                            TABLETRANSACTIONS, C_ID, C_TYPE, C_COMPANY_ID,
                            C_PERSON_ID, C_NAME, C_TAG_ID, C_STATUS,
                            C_TAG_SCAN_TIME, C_TAG_SENTSERVER_TIME,
                            C_TRANSACTIONS_LATITUDE, C_TRANSACTIONS_LONGITUDE,
                            C_DRIVER);

            db.execSQL(sqlToCreateTransactionsTable);
            Log.e(TAG, "oncreate " + sqlToCreateTransactionsTable);

}

Below is my logcat.

11-14 14:56:38.460: E/RR3ContentProvider(31791): inside RR3ContentProvider onCreate
11-14 14:56:38.510: E/art(31791): dlopen("/data/app-lib/com.carefreegroup.rr3-2/libstlport_shared.so", RTLD_LAZY) failed: dlopen failed: "/data/app-lib/com.carefreegroup.rr3-2/libstlport_shared.so" has unexpected e_machine: 3
11-14 14:56:38.510: E/AndroidRuntime(31791): FATAL EXCEPTION: main
11-14 14:56:38.510: E/AndroidRuntime(31791): Process: com.carefreegroup.rr3, PID: 31791
11-14 14:56:38.510: E/AndroidRuntime(31791): java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app-lib/com.carefreegroup.rr3-2/libstlport_shared.so" has unexpected e_machine: 3
11-14 14:56:38.510: E/AndroidRuntime(31791):    at java.lang.Runtime.loadLibrary(Runtime.java:364)
11-14 14:56:38.510: E/AndroidRuntime(31791):    at java.lang.System.loadLibrary(System.java:533)
11-14 14:56:38.510: E/AndroidRuntime(31791):    at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:118)
11-14 14:56:38.510: E/AndroidRuntime(31791):    at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:113)
11-14 14:56:38.510: E/AndroidRuntime(31791):    at com.carefreegroup.rr3.LoginValidate.<init>(LoginValidate.java:189)
11-14 14:56:38.510: E/AndroidRuntime(31791):    at com.carefreegroup.rr3.NfcScannerApplication.onCreate(NfcScannerApplication.java:840)
11-14 14:56:38.510: E/AndroidRuntime(31791):    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
11-14 14:56:38.510: E/AndroidRuntime(31791):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4924)
11-14 14:56:38.510: E/AndroidRuntime(31791):    at android.app.ActivityThread.access$1500(ActivityThread.java:153)
11-14 14:56:38.510: E/AndroidRuntime(31791):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)
11-14 14:56:38.510: E/AndroidRuntime(31791):    at android.os.Handler.dispatchMessage(Handler.java:102)
11-14 14:56:38.510: E/AndroidRuntime(31791):    at android.os.Looper.loop(Looper.java:157)
11-14 14:56:38.510: E/AndroidRuntime(31791):    at android.app.ActivityThread.main(ActivityThread.java:5633)
11-14 14:56:38.510: E/AndroidRuntime(31791):    at java.lang.reflect.Method.invoke(Native Method)
11-14 14:56:38.510: E/AndroidRuntime(31791):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:896)
11-14 14:56:38.510: E/AndroidRuntime(31791):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:712)

Does anyone know why i'm getting the unsatisfiedLinkError?

I call

SQLiteDatabase.loadLibs(context);

before a make a call to the DB, but i think the libstlport_shared.so is not loading properly.

Thanks in advance

Matt

0

There are 0 answers