【发布时间】:2019-06-17 13:23:59
【问题描述】:
我将 GreenDAO 与 SQLCipher 一起使用。在我将 SQLCipher 从 3.5.4 升级到 4.2.0 后,我的应用程序无法访问旧的加密数据库。我已经搜索了一个解决方案,发现我需要在 SQLiteDatabaseHook 的 postKey 中运行 PRAGMA cipher_migrate 来迁移我的数据库。我尝试了以下方法,但没有解决:
SQLiteDatabaseHook hook = new SQLiteDatabaseHook() {
@Override
public void preKey(net.sqlcipher.database.SQLiteDatabase database) {}
@Override
public void postKey(net.sqlcipher.database.SQLiteDatabase database) {
SQLiteDatabase.loadLibs(context);
database.execSQL("PRAGMA key = '" + key + "';");
database.execSQL("PRAGMA cipher_migrate;");
}
};
try {
logger.d(TAG, "before openOrCreateDatabase");
SQLiteDatabase sqLiteDatabase = net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase("DB.db", password, null, hook);
logger.d(TAG, "before EncryptedDatabase");
db = new EncryptedDatabase(sqLiteDatabase);
logger.d(TAG, "DB session is encrypted");
return new DaoMaster(db).newSession();
} catch (Exception e) {
我收到此错误:
No implementation found for void net.sqlcipher.database.SQLiteDatabase.dbopen(java.lang.String, int) (tried Java_net_sqlcipher_database_SQLiteDatabase_dbopen and Java_net_sqlcipher_database_SQLiteDatabase_dbopen__Ljava_lang_String_2I)
Could not dispatch event: class com.*.LoginResponse to subscribing class class com..LoginViewModel
java.lang.UnsatisfiedLinkError: No implementation found for void net.sqlcipher.database.SQLiteDatabase.dbopen(java.lang.String, int) (tried Java_net_sqlcipher_database_SQLiteDatabase_dbopen and Java_net_sqlcipher_database_SQLiteDatabase_dbopen__Ljava_lang_String_2I)
at net.sqlcipher.database.SQLiteDatabase.dbopen(Native Method)
at net.sqlcipher.database.SQLiteDatabase.openDatabaseInternal(SQLiteDatabase.java:3)
at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:10)
at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:7)
at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:5)
at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:3)
at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:3)
at com.elt.passsystem.infrastructure.di.modules.GreenDAOModule.provideDAO(GreenDAOModule.java:8)
at com.elt.passsystem.infrastructure.di.modules.GreenDAOModule_ProvideDAOFactory.get(GreenDAOModule_ProvideDAOFactory.java:3)
at com.elt.passsystem.infrastructure.di.modules.GreenDAOModule_ProvideDAOFactory.get(GreenDAOModule_ProvideDAOFactory.java:1)
【问题讨论】:
标签: android sqlite greendao sqlcipher