Android 房间数据库的几个不同的崩溃 - 不知道为什么
Several different crashes with Android Room database - NO IDEA WHY
我们最近在使用 Android 的房间数据库时遇到了一些问题。
崩溃只发生在某些用户身上,但我无法在我的测试设备或模拟器上重现它。
(这有时也会发生在 Firebase 测试设备上)
有一些例外似乎都是相关的。
所有这些异常都发生在我们 Dao 的不同行中,由 Room 生成。
(查询、插入、更新或删除)。
CursorWindowAllocationException: Cursor window allocation of 2048 kb failed.
IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: ‘/whatever/database’
SQLiteDiskIOException: disk I/O error (code 266)
SQLiteDiskIOException: disk I/O error (code 778)
SQLiteDatabaseCorruptException: file is encrypted or is not a database (code 26)
SQLiteException: Failed to change locale for db ‘/whatever/database' to 'fr_FR'.
我尝试过的:
- 严格模式 'detectLeakedClosableObjects()'
- 增加光标的窗口大小
- 将几乎所有数据库调用移动到顺序执行器(除了 LiveData 的查询实现)
None 这些方法有帮助,错误仍然存在。
LiveData 的查询是唯一一个 没有卸载默认数据库执行器的查询,因为我找不到这样做的方法。
我怀疑这可能是问题所在,但我不完全确定。
这是 LiveData 查询
@Query("SELECT * FROM alarms WHERE deleted =0 ORDER BY isActive DESC, hourOfDay, minuteOfHour")
LiveData<List<Alarm>> getLiveAlarmList();
异常示例:
Fatal Exception: android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed.
at android.database.CursorWindow.(CursorWindow.java:108)
at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198)
at android.database.sqlite.SQLiteCursor.clearOrCreateWindow(SQLiteCursor.java:300)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:138)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132)
at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:219)
at android.database.AbstractCursor.moveToNext(AbstractCursor.java:268)
at android.arch.persistence.room.InvalidationTracker.checkUpdatedTable(SourceFile:358)
at android.arch.persistence.room.InvalidationTracker.run(SourceFile:329)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:762)
这个似乎源自 Room 的 LiveData InvalidationTracker class。
Fatal Exception: android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. # Open Cursors=1 (# cursors opened by this proc=1)
at android.database.CursorWindow.(CursorWindow.java:108)
at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:225)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:149)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:143)
at com.sofaking.moonworshipper.database.room.AlarmDao_Impl.getAllAlarms(SourceFile:458)
at com.sofaking.moonworshipper.database.AlarmHelper.getAllAlarms(SourceFile:29)
at com.sofaking.moonworshipper.registration.DefaultAlarmRegistrationImpl.onCancelPendingAlarms(SourceFile:36)
at com.sofaking.moonworshipper.registration.BaseAlarmRegistrationImpl$start$runnable.run(SourceFile:26)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
虽然这个来自查询 "all alarms" 的服务。请注意,'AlarmDao_Impl.getAllAlarms' 是由 Room 生成的,并且在完成后确实关闭了游标。
Fatal Exception: android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 266)
at android.database.sqlite.SQLiteConnection.nativeExecuteForCursorWindow(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.executeForCursorWindow(SQLiteConnection.java:1015)
at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:836)
at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:147)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:136)
at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:197)
at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:237)
at android.arch.persistence.room.RoomOpenHelper.checkIdentity(SourceFile:127)
at android.arch.persistence.room.RoomOpenHelper.onOpen(SourceFile:115)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen(SourceFile:151)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:266)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(SourceFile:96)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(SourceFile:54)
at android.arch.persistence.room.RoomDatabase.query(SourceFile:233)
at com.sofaking.moonworshipper.database.room.AlarmDao_Impl.compute(SourceFile:555)
at com.sofaking.moonworshipper.database.room.AlarmDao_Impl.compute(SourceFile:541)
at android.arch.lifecycle.ComputableLiveData.run(SourceFile:100)
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)
另一个 LiveData 查询崩溃。
Fatal Exception: android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 778)
at android.database.sqlite.SQLiteConnection.nativeExecute(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.execute(SQLiteConnection.java:561)
at android.database.sqlite.SQLiteSession.endTransactionUnchecked(SQLiteSession.java:437)
at android.database.sqlite.SQLiteSession.endTransaction(SQLiteSession.java:401)
at android.database.sqlite.SQLiteDatabase.endTransaction(SQLiteDatabase.java:528)
at android.arch.persistence.db.framework.FrameworkSQLiteDatabase.endTransaction(SourceFile:90)
at android.arch.persistence.room.RoomDatabase.endTransaction(SourceFile:261)
at com.sofaking.moonworshipper.database.room.AlarmDao_Impl.update(SourceFile:188)
at com.sofaking.moonworshipper.registration.DefaultAlarmRegistrationImpl.onCalculateAlarms(SourceFile:58)
at com.sofaking.moonworshipper.registration.BaseAlarmRegistrationImpl$start$runnable.run(SourceFile:37)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
这来自更新对象实例(也由 Room 处理)
Fatal Exception: android.database.sqlite.SQLiteDatabaseCorruptException: file is encrypted or is not a database (code 26)
at android.database.sqlite.SQLiteConnection.nativeExecuteForCursorWindow(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.executeForCursorWindow(SQLiteConnection.java:845)
at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:836)
at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:143)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132)
at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:219)
at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:258)
at android.arch.persistence.room.RoomOpenHelper.hasRoomMasterTable(SourceFile:155)
at android.arch.persistence.room.RoomOpenHelper.checkIdentity(SourceFile:123)
at android.arch.persistence.room.RoomOpenHelper.onOpen(SourceFile:115)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen(SourceFile:151)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:266)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(SourceFile:96)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(SourceFile:54)
at android.arch.persistence.room.RoomDatabase.query(SourceFile:233)
at com.sofaking.moonworshipper.database.room.AlarmDao_Impl.compute(SourceFile:321)
at com.sofaking.moonworshipper.database.room.AlarmDao_Impl.compute(SourceFile:307)
at android.arch.lifecycle.ComputableLiveData.run(SourceFile:100)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
同样,似乎来自 LiveData 的 AlarmDao_Impl$4.compute() 方法
Fatal Exception: android.database.sqlite.SQLiteException: Failed to change locale for db '/data/user_de/0/com.sofaking.moonworshipper/databases/alarm-database' to 'fr_FR'.
at android.database.sqlite.SQLiteConnection.setLocaleFromConfiguration(SQLiteConnection.java:402)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:223)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:198)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
at android.database.sqlite.SQLiteConnectionPool.tryAcquireNonPrimaryConnectionLocked(SQLiteConnectionPool.java:899)
at android.database.sqlite.SQLiteConnectionPool.waitForConnection(SQLiteConnectionPool.java:609)
at android.database.sqlite.SQLiteConnectionPool.acquireConnection(SQLiteConnectionPool.java:348)
at android.database.sqlite.SQLiteSession.acquireConnection(SQLiteSession.java:894)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:586)
at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1353)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1328)
at android.arch.persistence.db.framework.FrameworkSQLiteDatabase.query(SourceFile:161)
at android.arch.persistence.room.RoomDatabase.query(SourceFile:233)
at com.sofaking.moonworshipper.database.room.AlarmDao_Impl.getAllAlarms(SourceFile:438)
at com.sofaking.moonworshipper.database.AlarmHelper.getAllAlarms(SourceFile:29)
at com.sofaking.moonworshipper.registration.DefaultAlarmRegistrationImpl.onCancelPendingAlarms(SourceFile:36)
at com.sofaking.moonworshipper.registration.BaseAlarmRegistrationImpl$start$runnable.run(SourceFile:26)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
与第二个 CursorWindowAllocationException 相同的区域,但崩溃不同
最终,错误与数据库本身无关。
我有一些图像资源未调整为 MDPI、HDPI 或 XHDPI。它们仅在 XXHDPI 中提供。
引用另一个帖子的回答:
如果您查找 CursorWindowAllocationException
的来源,它会显示:
This exception is thrown when a CursorWindow couldn't be allocated,
most probably due to memory not being available.
显然,由于图像占用了应用程序的大量堆内存,游标无法自行分配。
现在我遇到了 none 次崩溃。
我们最近在使用 Android 的房间数据库时遇到了一些问题。
崩溃只发生在某些用户身上,但我无法在我的测试设备或模拟器上重现它。 (这有时也会发生在 Firebase 测试设备上)
有一些例外似乎都是相关的。
所有这些异常都发生在我们 Dao 的不同行中,由 Room 生成。
(查询、插入、更新或删除)。
CursorWindowAllocationException: Cursor window allocation of 2048 kb failed.
IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: ‘/whatever/database’
SQLiteDiskIOException: disk I/O error (code 266)
SQLiteDiskIOException: disk I/O error (code 778)
SQLiteDatabaseCorruptException: file is encrypted or is not a database (code 26)
SQLiteException: Failed to change locale for db ‘/whatever/database' to 'fr_FR'.
我尝试过的:
- 严格模式 'detectLeakedClosableObjects()'
- 增加光标的窗口大小
- 将几乎所有数据库调用移动到顺序执行器(除了 LiveData 的查询实现)
None 这些方法有帮助,错误仍然存在。
LiveData 的查询是唯一一个 没有卸载默认数据库执行器的查询,因为我找不到这样做的方法。 我怀疑这可能是问题所在,但我不完全确定。
这是 LiveData 查询
@Query("SELECT * FROM alarms WHERE deleted =0 ORDER BY isActive DESC, hourOfDay, minuteOfHour")
LiveData<List<Alarm>> getLiveAlarmList();
异常示例:
Fatal Exception: android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed.
at android.database.CursorWindow.(CursorWindow.java:108)
at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198)
at android.database.sqlite.SQLiteCursor.clearOrCreateWindow(SQLiteCursor.java:300)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:138)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132)
at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:219)
at android.database.AbstractCursor.moveToNext(AbstractCursor.java:268)
at android.arch.persistence.room.InvalidationTracker.checkUpdatedTable(SourceFile:358)
at android.arch.persistence.room.InvalidationTracker.run(SourceFile:329)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:762)
这个似乎源自 Room 的 LiveData InvalidationTracker class。
Fatal Exception: android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. # Open Cursors=1 (# cursors opened by this proc=1)
at android.database.CursorWindow.(CursorWindow.java:108)
at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:225)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:149)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:143)
at com.sofaking.moonworshipper.database.room.AlarmDao_Impl.getAllAlarms(SourceFile:458)
at com.sofaking.moonworshipper.database.AlarmHelper.getAllAlarms(SourceFile:29)
at com.sofaking.moonworshipper.registration.DefaultAlarmRegistrationImpl.onCancelPendingAlarms(SourceFile:36)
at com.sofaking.moonworshipper.registration.BaseAlarmRegistrationImpl$start$runnable.run(SourceFile:26)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
虽然这个来自查询 "all alarms" 的服务。请注意,'AlarmDao_Impl.getAllAlarms' 是由 Room 生成的,并且在完成后确实关闭了游标。
Fatal Exception: android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 266)
at android.database.sqlite.SQLiteConnection.nativeExecuteForCursorWindow(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.executeForCursorWindow(SQLiteConnection.java:1015)
at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:836)
at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:147)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:136)
at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:197)
at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:237)
at android.arch.persistence.room.RoomOpenHelper.checkIdentity(SourceFile:127)
at android.arch.persistence.room.RoomOpenHelper.onOpen(SourceFile:115)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen(SourceFile:151)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:266)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(SourceFile:96)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(SourceFile:54)
at android.arch.persistence.room.RoomDatabase.query(SourceFile:233)
at com.sofaking.moonworshipper.database.room.AlarmDao_Impl.compute(SourceFile:555)
at com.sofaking.moonworshipper.database.room.AlarmDao_Impl.compute(SourceFile:541)
at android.arch.lifecycle.ComputableLiveData.run(SourceFile:100)
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)
另一个 LiveData 查询崩溃。
Fatal Exception: android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 778)
at android.database.sqlite.SQLiteConnection.nativeExecute(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.execute(SQLiteConnection.java:561)
at android.database.sqlite.SQLiteSession.endTransactionUnchecked(SQLiteSession.java:437)
at android.database.sqlite.SQLiteSession.endTransaction(SQLiteSession.java:401)
at android.database.sqlite.SQLiteDatabase.endTransaction(SQLiteDatabase.java:528)
at android.arch.persistence.db.framework.FrameworkSQLiteDatabase.endTransaction(SourceFile:90)
at android.arch.persistence.room.RoomDatabase.endTransaction(SourceFile:261)
at com.sofaking.moonworshipper.database.room.AlarmDao_Impl.update(SourceFile:188)
at com.sofaking.moonworshipper.registration.DefaultAlarmRegistrationImpl.onCalculateAlarms(SourceFile:58)
at com.sofaking.moonworshipper.registration.BaseAlarmRegistrationImpl$start$runnable.run(SourceFile:37)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
这来自更新对象实例(也由 Room 处理)
Fatal Exception: android.database.sqlite.SQLiteDatabaseCorruptException: file is encrypted or is not a database (code 26)
at android.database.sqlite.SQLiteConnection.nativeExecuteForCursorWindow(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.executeForCursorWindow(SQLiteConnection.java:845)
at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:836)
at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:143)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132)
at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:219)
at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:258)
at android.arch.persistence.room.RoomOpenHelper.hasRoomMasterTable(SourceFile:155)
at android.arch.persistence.room.RoomOpenHelper.checkIdentity(SourceFile:123)
at android.arch.persistence.room.RoomOpenHelper.onOpen(SourceFile:115)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen(SourceFile:151)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:266)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(SourceFile:96)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(SourceFile:54)
at android.arch.persistence.room.RoomDatabase.query(SourceFile:233)
at com.sofaking.moonworshipper.database.room.AlarmDao_Impl.compute(SourceFile:321)
at com.sofaking.moonworshipper.database.room.AlarmDao_Impl.compute(SourceFile:307)
at android.arch.lifecycle.ComputableLiveData.run(SourceFile:100)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
同样,似乎来自 LiveData 的 AlarmDao_Impl$4.compute() 方法
Fatal Exception: android.database.sqlite.SQLiteException: Failed to change locale for db '/data/user_de/0/com.sofaking.moonworshipper/databases/alarm-database' to 'fr_FR'.
at android.database.sqlite.SQLiteConnection.setLocaleFromConfiguration(SQLiteConnection.java:402)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:223)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:198)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
at android.database.sqlite.SQLiteConnectionPool.tryAcquireNonPrimaryConnectionLocked(SQLiteConnectionPool.java:899)
at android.database.sqlite.SQLiteConnectionPool.waitForConnection(SQLiteConnectionPool.java:609)
at android.database.sqlite.SQLiteConnectionPool.acquireConnection(SQLiteConnectionPool.java:348)
at android.database.sqlite.SQLiteSession.acquireConnection(SQLiteSession.java:894)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:586)
at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1353)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1328)
at android.arch.persistence.db.framework.FrameworkSQLiteDatabase.query(SourceFile:161)
at android.arch.persistence.room.RoomDatabase.query(SourceFile:233)
at com.sofaking.moonworshipper.database.room.AlarmDao_Impl.getAllAlarms(SourceFile:438)
at com.sofaking.moonworshipper.database.AlarmHelper.getAllAlarms(SourceFile:29)
at com.sofaking.moonworshipper.registration.DefaultAlarmRegistrationImpl.onCancelPendingAlarms(SourceFile:36)
at com.sofaking.moonworshipper.registration.BaseAlarmRegistrationImpl$start$runnable.run(SourceFile:26)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
与第二个 CursorWindowAllocationException 相同的区域,但崩溃不同
最终,错误与数据库本身无关。 我有一些图像资源未调整为 MDPI、HDPI 或 XHDPI。它们仅在 XXHDPI 中提供。
引用另一个帖子的回答:
如果您查找 CursorWindowAllocationException
的来源,它会显示:
This exception is thrown when a CursorWindow couldn't be allocated, most probably due to memory not being available.
显然,由于图像占用了应用程序的大量堆内存,游标无法自行分配。
现在我遇到了 none 次崩溃。