我试图在我的项目中设置安全空间库,但是我遇到了一个神秘的错误。
对于这个例子,我使用谷歌的todo-mvp,所以他们正在使用Dagger2和RxJava。
在TodoDatabase.class中的我有一堆代码:
fun getInstance(context: Context): ToDoDatabase {
synchronized(lock) {
if (INSTANCE == null) {
val admin = "password123".toCharArray()
val factory = SafeHelperFactory(admin)
INSTANCE = Room.databaseBuilder(context.applicationContext, ToDoDatabase::class.java, "Tasks.db")
.openHelperFactory(factory)
.build()
SQLCipherUtils.encrypt(context, "Tasks.db", admin)
val state = SQLCipherUtils.getDatabaseState(context, "Tasks.db")
if (state.name == SQLCipherUtils.State.ENCRYPTED.name)
Log.e("test", "Database encrypted - $state")
else
Log.e("test", "Database encrypted - $state")
}
return INSTANCE!!
}
}
执行此行INSTANCE = Room.databaseBuilder(context.applicationContext, ToDoDatabase::class.java, "Tasks.db").openHelperFactory(factory).build()
我发现了错误:
E/art: Failed to register native method net.sqlcipher.database.SQLiteDatabase.native_getDbLookaside()I in /data/app/com.example.android.architecture.blueprints.todomvp.mock-1/split_lib_dependencies_apk.apk:classes5.dex
----- class 'Lnet/sqlcipher/database/SQLiteDatabase;' cl=0x12c81280 -----
objectSize=1096 (128 from super)