我在应用程序的模型中添加了一个字段。
模型的本地持久性由Room Persistence Library管理。
很遗憾,您忘记创建Migration并将新版本的应用程序上传到Google Play。
现在,有些人无法打开该应用程序。当他们打开它时,它会自动关闭。这是我在Google Play控制台上获得的堆栈跟踪。
java.lang.IllegalStateException:
at android.database.sqlite.SQLiteClosable.acquireReference (SQLiteClosable.java:55)
at android.database.sqlite.SQLiteDatabase.executeSql (SQLiteDatabase.java:2197)
at android.database.sqlite.SQLiteDatabase.execSQL (SQLiteDatabase.java:2142)
at android.arch.persistence.db.framework.FrameworkSQLiteDatabase.execSQL (FrameworkSQLiteDatabase.java:240)
at android.arch.persistence.room.RoomOpenHelper.createMasterTableIfNotExists (RoomOpenHelper.java:131)
at android.arch.persistence.room.RoomOpenHelper.checkIdentity (RoomOpenHelper.java:107)
at android.arch.persistence.room.RoomOpenHelper.onOpen (RoomOpenHelper.java:100)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen (FrameworkSQLiteOpenHelper.java:133)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked (SQLiteOpenHelper.java:349)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:238)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase (FrameworkSQLiteOpenHelper.java:93)
at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase (FrameworkSQLiteOpenHelper.java:54)
at android.arch.persistence.room.RoomDatabase.inTransaction (RoomDatabase.java:305)
at android.arch.persistence.room.InvalidationTracker$1.run (InvalidationTracker.java:281)
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)
我现在不能简单地生成一个迁移,因为可能已经为某些用户运行了其他迁移。我认为新用户已经解决了问题,因此他们也无法运行迁移。
注意:存储的数据并不是很重要,因此,如果我删除整个数据库并再次创建它,不会有什么大麻烦。
当我抓到DROP DATABASE
时该如何做IllegalStateException
动作?还是有更好的解决方案?