1

I'm trying to set up Safe-room lib in my project but I got a mysterious error.

For this example, I'm using todo-mvp by Google, so they're using Dagger2 and RxJava.

in TodoDatabase.class I have the bunch of code:

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!!
        }
    }

After executing this line INSTANCE = Room.databaseBuilder(context.applicationContext, ToDoDatabase::class.java, "Tasks.db").openHelperFactory(factory).build()

I caught the error:

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)
Douglas Mesquita
  • 860
  • 1
  • 13
  • 30
  • 1
    See [this issue](https://github.com/sqlcipher/android-database-sqlcipher/issues/98). Check your ProGuard settings and make sure that your APK has the right compiled editions of the `.so` files, for whatever architectures you are trying to support. BTW, CWAC-SafeRoom is up to `0.3.4`. – CommonsWare Apr 11 '18 at 17:27

0 Answers0