I copied the database files to my emulator and upon starting the app, I received the following runtime error
2019-09-25 09:25:31.190 4511-4526/? E/AndroidRuntime: FATAL EXCEPTION: arch_disk_io_0
Process: edu.mines.criminalintentbnr4k, PID: 4511
java.lang.RuntimeException: Exception while computing database live data.
at androidx.room.RoomTrackingLiveData$1.run(RoomTrackingLiveData.java:92)
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)
Caused by: java.lang.IllegalStateException: Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number.
at androidx.room.RoomOpenHelper.checkIdentity(RoomOpenHelper.java:139)
at androidx.room.RoomOpenHelper.onOpen(RoomOpenHelper.java:119)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen(FrameworkSQLiteOpenHelper.java:142)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:266)
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.inTransaction(RoomDatabase.java:452)
at androidx.room.RoomDatabase.assertNotSuspendingTransaction(RoomDatabase.java:275)
at androidx.room.RoomDatabase.query(RoomDatabase.java:304)
at androidx.room.util.DBUtil.query(DBUtil.java:54)
at com.criminalintentbnr4k.database.CrimeDao_Impl$1.call(CrimeDao_Impl.java:38)
at com.criminalintentbnr4k.database.CrimeDao_Impl$1.call(CrimeDao_Impl.java:35)
at androidx.room.RoomTrackingLiveData$1.run(RoomTrackingLiveData.java:90)
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)
Upon inspection of the generated Java code and the existing database schema, the provided database file does not contain a column for the requiresPolice
field that was added from the Chapter 9 challenge.
If you’re working through the book, then make sure you undo this challenge when using the prepopulated database file. I think one of the best features of this book is carrying the challenges through since to continue patching the additions you need to have a strong understanding of the topics presented in each chapter. I realize this is temporary since at this point we don’t have the features yet to popualte the database, it’s just unfortunate to need to undo a prior step.