androidx 使用 SQLiteDiskIOException 使应用程序崩溃

androidx crashing the app with a SQLiteDiskIOException

我的 android 应用程序中没有任何与数据库相关的代码。不过,我确实看到在我的应用程序中使用 androidx 导致与数据库相关的崩溃。请帮助我理解并找到解决此问题的方法。

Fatal Exception: android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 4874): , while compiling: PRAGMA journal_mode
       at android.database.sqlite.SQLiteConnection.nativePrepareStatement(SQLiteConnection.java)
       at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:897)
       at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:642)
       at android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:323)
       at android.database.sqlite.SQLiteConnection.setWalModeFromConfiguration(SQLiteConnection.java:294)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:218)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:196)
       at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:464)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:186)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:178)
       at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:916)
       at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:893)
       at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:796)
       at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:1309)
       at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:268)
       at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
       at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
       at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:92)
       at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:53)
       at androidx.room.RoomDatabase.beginTransaction(RoomDatabase.java:328)
       at androidx.work.impl.utils.ForceStopRunnable.cleanUp(ForceStopRunnable.java:135)
       at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:79)
       at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:75)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
       at java.lang.Thread.run(Thread.java:818)

基于 this issue and this issue,您可能磁盘不足 space。

WorkManager 将作业信息存储在 SQLite 数据库中,这就是您崩溃的地方。

看来 WorkManager (2.6.x) 的未来版本可能会提供更好的 API 来处理这种情况。