使用带有SQLCipher的项目中的libstlport_shared.so时出现UnsatisfiedLinkError

时间:2014-11-14 15:07:46

标签: android sqlcipher

我有一个有SQLite DB的应用程序。我需要加密这个数据库。 我已经将SqlCipher for Android视为解决方案,并查看了以下页面。

SQLCipher

以下主题的设置接近我的原始应用。它有一个带有SqliteOpenHelper内部类的类。

SQLCipher openhelper example

我已将3个jar文件复制到我项目的lib文件夹中,如第1教程所述。

公地codec.jar

番石榴r09.jar

sqlcipher.jar

我还将.so文件复制到libs / armeabi

的文件夹中

libdatabase_sqlcipher.so

libsqlcipher_android.so

libstlport_shared.so

我认为最后一个libstlport_shared.so引起了问题,而且我已经读过一些我必须明确加载它的地方?

下面是我的数据库类,它创建了一个SQLCipher数据库和表。

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);

}

下面是我的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)

有谁知道我为什么会得到不满意的LinkError?

我打电话

SQLiteDatabase.loadLibs(context);

在调用DB之前,但我认为libstlport_shared.so没有正确加载。

提前致谢

马特

0 个答案:

没有答案