SqlCipher:UnSatisfiedLinkError dlopen 失败:无法打开符号

SqlCipher :UnSatisfiedLinkError dlopen failed :cannot open symbol

我必须使用 sqlite 进行密码加密和解密 database.I 引用了这个 github post

我在 runtime.I 处收到 failed: dlopen failed: cannot locate symbol 异常,我指出了下面代码中的错误行。

我尝试了this and this。但它并没有帮助我解决这个问题。

堆栈跟踪:

04-15 01:45:02.767: E/dalvikvm(1423): dlopen("/data/app-lib/com.drspaceboo.sqlite2sqlcipher-1/libdatabase_sqlcipher.so") failed: dlopen failed: cannot locate symbol "_ZN7android10MemoryBaseC1ERKNS_2spINS_11IMemoryHeapEEElj" referenced by "libdatabase_sqlcipher.so"...
04-15 01:45:02.767: D/AndroidRuntime(1423): Shutting down VM
04-15 01:45:02.777: W/dalvikvm(1423): threadid=1: thread exiting with uncaught exception (group=0xb3b04ba8)
04-15 01:45:02.777: E/AndroidRuntime(1423): FATAL EXCEPTION: main
04-15 01:45:02.777: E/AndroidRuntime(1423): Process: com.drspaceboo.sqlite2sqlcipher, PID: 1423
04-15 01:45:02.777: E/AndroidRuntime(1423): java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZN7android10MemoryBaseC1ERKNS_2spINS_11IMemoryHeapEEElj" referenced by "libdatabase_sqlcipher.so"...
04-15 01:45:02.777: E/AndroidRuntime(1423):     at java.lang.Runtime.loadLibrary(Runtime.java:364)
04-15 01:45:02.777: E/AndroidRuntime(1423):     at java.lang.System.loadLibrary(System.java:526)
04-15 01:45:02.777: E/AndroidRuntime(1423):     at info.guardianproject.database.sqlcipher.SQLiteDatabase.loadLibs(SQLiteDatabase.java:106)
04-15 01:45:02.777: E/AndroidRuntime(1423):     at com.drspaceboo.sqlite2sqlcipher.SQLite2SQLCipher.onCreate(SQLite2SQLCipher.java:50)
04-15 01:45:02.777: E/AndroidRuntime(1423):     at android.app.Activity.performCreate(Activity.java:5231)
04-15 01:45:02.777: E/AndroidRuntime(1423):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-15 01:45:02.777: E/AndroidRuntime(1423):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
04-15 01:45:02.777: E/AndroidRuntime(1423):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
04-15 01:45:02.777: E/AndroidRuntime(1423):     at android.app.ActivityThread.access0(ActivityThread.java:135)
04-15 01:45:02.777: E/AndroidRuntime(1423):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
04-15 01:45:02.777: E/AndroidRuntime(1423):     at android.os.Handler.dispatchMessage(Handler.java:102)
04-15 01:45:02.777: E/AndroidRuntime(1423):     at android.os.Looper.loop(Looper.java:136)
04-15 01:45:02.777: E/AndroidRuntime(1423):     at android.app.ActivityThread.main(ActivityThread.java:5017)
04-15 01:45:02.777: E/AndroidRuntime(1423):     at java.lang.reflect.Method.invokeNative(Native Method)
04-15 01:45:02.777: E/AndroidRuntime(1423):     at java.lang.reflect.Method.invoke(Method.java:515)
04-15 01:45:02.777: E/AndroidRuntime(1423):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-15 01:45:02.777: E/AndroidRuntime(1423):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-15 01:45:02.777: E/AndroidRuntime(1423):     at dalvik.system.NativeStart.main(Native Method)

Sqlite2SQLCipher.java:

public class SQLite2SQLCipher extends Activity
{
    /*  
     * Please replace the following variables with the ones
     * relevant to your application
     */
    private static final String SQLITE_FILE = "test.sqlite";
    private static final String DB_NAME = "test.db";
    private static final String DB_PASSWORD = "testPassword";
    //Stop replacing here

    private static final String DEBUG_TAG = "SQLite2SQLCipher";

    private SQLiteDatabase database;
    private ProgressDialog progressDialog;

    /*
     * (non-Javadoc)
     * @see android.app.Activity#onCreate(android.os.Bundle)
     */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        //Loading the SQLCipher libraries
        SQLiteDatabase.loadLibs(this);  ----->50th line

        //Preparing the database directories and file to be opened
        File databaseFile = getDatabasePath(DB_NAME);
        databaseFile.mkdirs();
        databaseFile.delete();

        //Opening or Creating the database with our specified password
        database = SQLiteDatabase.openOrCreateDatabase(databaseFile, DB_PASSWORD, null);

        //Making a progress dialog so we can see that the database is still being loaded
        progressDialog = new ProgressDialog(this);
        progressDialog.setCancelable(false);
        progressDialog.setMessage("Creating database");
        progressDialog.show();

        /*
         * Creating the database from the .sqlite file. We do this in
         * an AsyncTask so that we aren't locking the UI thread.
         */
        new CreateDatabaseFromFileTask().execute();
    }

  private class CreateDatabaseFromFileTask extends AsyncTask<Void, Void, Void>
    {
        @Override
        protected Void doInBackground(Void... params)
        {
            StringBuilder statement = new StringBuilder();
            String line;
            int lineCount = 1;
            int statementCount = 1;
            BufferedReader reader = null;

            try
            {
                //Opening the .sqlite file from the Assets folder
                reader = new BufferedReader(new InputStreamReader(getAssets().open(SQLITE_FILE)));

                while((line = reader.readLine()) != null)
                {
                    //A very handy line count log
                    Log.d(DEBUG_TAG,"Reading line " + lineCount);
                    if(line.length() > 1)
                    {
                        statement.append(line);

                        //If this line is the end of the statement we run that statement
                        if(line.matches(".*;$"))
                        {
                            //Getting the string from the String Builder
                            String statementString = statement.toString();
                            statement = new StringBuilder();

                            //Logging the statement, this might help with debugging any problems you encounter
                            Log.d(DEBUG_TAG,"Statement #" + statementCount + "\"" + statementString + "\"");
                            statementCount++;

                            //Loading the statement into the database
                            database.execSQL(statementString);
                        }
                    }
                    lineCount++;
                }

                //Closing the progress dialog
                progressDialog.dismiss();
                //Updating the UI with a success message
                updateUIWithSuccess();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            finally
            {
                //Closing the buffered reader
                try
                {
                    reader.close();
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            //Closing the database
            database.close();
            return null;
        }
    }


}

在asset/test.sqlite中:

CREATE TABLE `user` (
  `ID` INTEGER NOT NULL PRIMARY KEY,
  `email` TEXT NOT NULL,
  `name` TEXT NOT NULL);

INSERT INTO `user` (`email`,`name`) VALUES ("test1@test.com", "Text User One");
/*
 * This is a test of the multiline comment removal
*/
INSERT INTO `user` (`email`,`name`) VALUES ("test2@test.com", "Text User Two");
-- This is a test of the single line comment removal
INSERT INTO `user` (`email`,`name`) VALUES ("test3@test.com", "Text User Three");

INSERT INTO `user` (`email`,`name`) VALUES ("test4@test.com", "Text User Four");
INSERT INTO `user` (`email`,`name`) VALUES ("test5@test.com", "Text User Five");

java 构建路径 -> 库:

任何人都可以帮助我 this.Thank 你。

Android 2.2.0 release

的 SQLCipher

更改本机 CursorWindow 以删除私有 android::MemoryBase

随着 2.2.0 的发布,我们可以发现 android OS 映射中的 sqlcipher 发生了很多变化。因此,由于 *.so 文件

而发生 UnsatisfiedLinkError

获取最新的二进制文件,可以找到 here,适用于 4.4