我想知道是否有办法为 SQLCipher 添加替代 LibraryLoader。
某些设备Huawei Enjoy 9s
(Android 5.1 rooted)和Nexus 4
(Android 6.0.1 not rooted)会产生下一次崩溃:
致命异常:java.lang.UnsatisfiedLinkError dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.application-1/base.apk"], nativeLibraryDirectories=[/data/app/com.application.app -1/lib/arm, /vendor/lib, /system/lib]]] 找不到“libsqlcipher.so”
如果可能,我如何找到要加载的适当库名称以及在哪里执行操作?
这是来自的代码SQLiteDatabase
:
/**
* Loads the native SQLCipher library into the application process.
*/
public static synchronized void loadLibs (Context context, File workingDir, LibraryLoader libraryLoader) {
libraryLoader.loadLibraries("sqlcipher");
// System.loadLibrary("stlport_shared");
// System.loadLibrary("sqlcipher_android");
// System.loadLibrary("database_sqlcipher");
// boolean systemICUFileExists = new File("/system/usr/icu/icudt46l.dat").exists();
// String icuRootPath = systemICUFileExists ? "/system/usr" : workingDir.getAbsolutePath();
// setICURoot(icuRootPath);
// if(!systemICUFileExists){
// loadICUData(context, workingDir);
// }
}
这就是我创建数据库实例的方式:
import net.sqlcipher.database.SQLiteDatabase
import net.sqlcipher.database.SupportFactory
...
val passphrase: ByteArray = SQLiteDatabase.getBytes((BuildConfig.ROOM_PASSPHRASE + session.getRoomUUID()).toCharArray())
val factory = SupportFactory(passphrase)
val instance = Room.databaseBuilder(context.applicationContext, MyDatabase::class.java, "MyDatabase")
.openHelperFactory(factory)
.fallbackToDestructiveMigration()
.build()
...