Hi guys, I’ve KMM project that uses Firebase database [<https://github.com/GitLiveApp/firebase-kotli...
l

Loe

over 2 years ago
Hi guys, I’ve KMM project that uses Firebase database [https://github.com/GitLiveApp/firebase-kotlin-sdk] and i’m getting an exception when offline caching is enabled. This issue only happens on the first app install, and doesn’t not occur after that:
E  com.google.firebase.database.DatabaseException: Failed to gain exclusive lock to Firebase Database's offline persistence. This generally means you are using Firebase Database from multiple processes in your app. Keep in mind that multi-process Android apps execute the code in your Application class in all processes, so you may need to avoid initializing FirebaseDatabase in your Application class. If you are intentionally using Firebase Database from multiple processes, you can only enable offline persistence (i.e. call setPersistenceEnabled(true)) in one of them.
    at com.google.firebase.database.android.SqlPersistenceStorageEngine.openDatabase(SqlPersistenceStorageEngine.java:861)
        . . . 
Caused by: android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5 SQLITE_BUSY): , while compiling: PRAGMA journal_mode
    at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
    at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1068)
    at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:811)
    at android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:419)