2015-04-16 3 views
0

Мне нужно выполнить шифрование и дешифрование passwod с использованием базы данных sqlite. Я ссылался на это github post.SqlCipher: UnSatisfiedLinkError dlopen не удалось: не удается открыть символ

Я получаю failed: dlopen failed: cannot locate symbol Исключение во время выполнения. Я указал строку ошибки в нижнем коде.

Я пробовал this и this. Но это не помогает мне решить эту проблему.

StackTrace:

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.access$800(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; 
     } 
    } 


} 

В актив/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 ("[email protected]", "Text User One"); 
/* 
* This is a test of the multiline comment removal 
*/ 
INSERT INTO `user` (`email`,`name`) VALUES ("[email protected]", "Text User Two"); 
-- This is a test of the single line comment removal 
INSERT INTO `user` (`email`,`name`) VALUES ("[email protected]", "Text User Three"); 

INSERT INTO `user` (`email`,`name`) VALUES ("[email protected]", "Text User Four"); 
INSERT INTO `user` (`email`,`name`) VALUES ("[email protected]", "Text User Five"); 

enter image description here

Java Build Path -> Библиотеки:

enter image description here

Любой человек может помочь мне с this.Thank вас.

+0

, что является целевым SDK? & Какова версия sqlcipher? –

+0

@HarshaVardhan target sdk version 19. Как проверить версию sqlcipher? Я опубликовал весь код. Я не видел версию sqlcipher – Steve

+0

. Нижняя версия sqlcipher не поддерживает 4.4 (19). Используйте 2.2.2, который работает на 4.4 –

ответ

1

SQLCipher для Android 2.2.0 release

Изменение к родному CursorWindow, чтобы удалить использование частного андроида :: MemoryBase

С выпуском 2.2.0, мы можем определить, есть много изменений произошло в sqlcipher на карте ОС Android. Таким образом, есть UnsatisfiedLinkError происходит из-за * .so файлов

Возьмите последние двоичные файлы, можно найти here, который работает на 4.4

+0

Это сработало. Но я получаю крах в приложении. Базовый сигнал 6 и Cant find net/sqlcipher/database/sqlitedatabase – Steve

+0

Последние бинарные файлы можно найти здесь [https: // www. zetetic.net/sqlcipher/open-source/). В настоящее время последняя версия - 3.3.0, бинарные файлы Harasha, о которых идет речь, являются намного более старыми версиями версии 2.2.0. –

Смежные вопросы