codelab-android-workmanager icon indicating copy to clipboard operation
codelab-android-workmanager copied to clipboard

Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number

Open kuiper-lee opened this issue 3 years ago • 9 comments

12-24 21:12:35.920 6675 8461 E AndroidRuntime: FATAL EXCEPTION: pool-8-thread-1 12-24 21:12:35.920 6675 8461 E AndroidRuntime: Process: com.coloros.sceneservice, PID: 6675 12-24 21:12:35.920 6675 8461 E AndroidRuntime: 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. 12-24 21:12:35.920 6675 8461 E AndroidRuntime: at androidx.room.RoomOpenHelper.checkIdentity(SourceFile:154) 12-24 21:12:35.920 6675 8461 E AndroidRuntime: at androidx.room.RoomOpenHelper.onOpen(SourceFile:135) 12-24 21:12:35.920 6675 8461 E AndroidRuntime: at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen(SourceFile:195) 12-24 21:12:35.920 6675 8461 E AndroidRuntime: at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:427) 12-24 21:12:35.920 6675 8461 E AndroidRuntime: at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:316) 12-24 21:12:35.920 6675 8461 E AndroidRuntime: at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(SourceFile:145) 12-24 21:12:35.920 6675 8461 E AndroidRuntime: at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(SourceFile:106) 12-24 21:12:35.920 6675 8461 E AndroidRuntime: at androidx.room.RoomDatabase.inTransaction(SourceFile:476) 12-24 21:12:35.920 6675 8461 E AndroidRuntime: at androidx.room.RoomDatabase.assertNotSuspendingTransaction(SourceFile:281) 12-24 21:12:35.920 6675 8461 E AndroidRuntime: at androidx.work.impl.model.SystemIdInfoDao_Impl.getWorkSpecIds(SourceFile:120) 12-24 21:12:35.920 6675 8461 E AndroidRuntime: at androidx.work.impl.background.systemjob.SystemJobScheduler.reconcileJobs(SourceFile:298) 12-24 21:12:35.920 6675 8461 E AndroidRuntime: at androidx.work.impl.utils.ForceStopRunnable.cleanUp(SourceFile:245) 12-24 21:12:35.920 6675 8461 E AndroidRuntime: at androidx.work.impl.utils.ForceStopRunnable.forceStopRunnable(SourceFile:212) 12-24 21:12:35.920 6675 8461 E AndroidRuntime: at androidx.work.impl.utils.ForceStopRunnable.run(SourceFile:108) 12-24 21:12:35.920 6675 8461 E AndroidRuntime: at androidx.work.impl.utils.SerialExecutor$Task.run(SourceFile:91) 12-24 21:12:35.920 6675 8461 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 12-24 21:12:35.920 6675 8461 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 12-24 21:12:35.920 6675 8461 E AndroidRuntime: at java.lang.Thread.run(Thread.java:920) 12-24 21:12:39.171 8703 9270 E AndroidRuntime: FATAL EXCEPTION: pool-9-thread-1

workManager version is 2.7.0-alpha05

kuiper-lee avatar Feb 24 '22 12:02 kuiper-lee

https://stackoverflow.com/questions/44197309/room-cannot-verify-the-data-integrity

alimuhammad1999 avatar Feb 13 '23 05:02 alimuhammad1999

邮件我已经收到

kuiper-lee avatar Feb 13 '23 05:02 kuiper-lee

If that is the case, most likely you should not increment the database version. Simply clearing app data will move you passed the exception. If your app is live, you will likely need to increment the database version and provide a proper migration.

If you do not increment the database (recommended):

You should clear the application's app data from Android settings. You might alternatively be able to uninstall the previous app version and then install the new version to get passed the exception. This latter approach does not work under certain conditions (such as when allow backup is enabled)

Since clearing application data always works, I take that route every time.

If you do increment the database version: You will need to write database migration code to account for any changes to the database schema. See here for information on migration.

Alternative to writing database migration code is to call fallbackToDestructiveMigration on the Room database builder. This is probably not a good idea as this change should not be published to actual users. Forgetting to remove this call and then forgetting to upgrade the database will result in data loss for users.

// Using this fallback is almost certainly a bad idea Database database = Room.databaseBuilder(context, Database.class, DATABASE_NAME) .fallbackToDestructiveMigration() .build(); Again, neither incrementing the database version nor falling back to destructive migration is necessary if the previous database schema is not live in the wild.

wilfredgicharu avatar Mar 27 '23 18:03 wilfredgicharu

邮件我已经收到

kuiper-lee avatar Mar 27 '23 18:03 kuiper-lee

没关系

On Mon, Mar 27, 2023 at 9:09 PM kuiper-lee @.***> wrote:

邮件我已经收到

— Reply to this email directly, view it on GitHub https://github.com/googlecodelabs/android-workmanager/issues/283#issuecomment-1485613120, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOIRMEE2E2KIJDZ5JNZIWADW6HJVBANCNFSM5PHI3L5Q . You are receiving this because you commented.Message ID: @.***>

wilfredgicharu avatar Mar 27 '23 19:03 wilfredgicharu

Simply uninstall the app and reinstall it. Error will be fixed

vipulm7 avatar Jun 15 '23 06:06 vipulm7

邮件我已经收到

kuiper-lee avatar Jun 15 '23 06:06 kuiper-lee