urbanairship / android-library

Urban Airship Android SDK
Other
109 stars 123 forks source link

Pre-packaged database has an invalid schema: richpush(com.urbanairship.messagecenter.MessageEntity #209

Closed halysongoncalves closed 2 years ago

halysongoncalves commented 2 years ago

Hello,

We have identified crash in `Pre-packaged database has an invalid schema: richpush(com.urbanairship.messagecenter.MessageEntity

Captura de Tela 2022-06-29 às 13 16 39

` that has affected our users

Fatal Exception: java.lang.IllegalStateException Pre-packaged database has an invalid schema: richpush(com.urbanairship.messagecenter.MessageEntity). Expected: TableInfo{name='richpush', columns={unread=Column{name='unread', type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=0, defaultValue='null'}, unread_orig=Column{name='unread_orig', type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=0, defaultValue='null'}, expiration_timestamp=Column{name='expiration_timestamp', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, message_id=Column{name='message_id', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, title=Column{name='title', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, message_url=Column{name='message_url', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, raw_message_object=Column{name='raw_message_object', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, deleted=Column{name='deleted', type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=0, defaultValue='null'}, message_read_url=Column{name='message_read_url', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, message_body_url=Column{name='message_body_url', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, extra=Column{name='extra', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}, _id=Column{name='_id', type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=1, defaultValue='null'}, timestamp=Column{name='timestamp', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0, defaultValue='null'}}, foreignKeys=[], indices=[Index{name='index_richpush_message_id', unique=true, columns=[message_id], orders=[ASC]}]} Found: TableInfo{name='richpush', columns={unread=Column{name='unread', type='INTEGER', affinity='3', notNull=false, primaryKeyPosition=0, defaultValue='null'}, <truncated: 1535 chars> androidx.room.RoomOpenHelper.checkIdentity (RoomOpenHelper.java:163) androidx.room.RoomOpenHelper.onOpen (RoomOpenHelper.java:135) androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen (FrameworkSQLiteOpenHelper.java:201) android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked (SQLiteOpenHelper.java:349) android.database.sqlite.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:238) androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase (FrameworkSQLiteOpenHelper.java:151) androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase (FrameworkSQLiteOpenHelper.java:112) androidx.room.RoomDatabase.inTransaction (RoomDatabase.java:706) androidx.room.RoomDatabase.assertNotSuspendingTransaction (RoomDatabase.java:483) com.urbanairship.messagecenter.MessageDao_Impl.getMessages (MessageDao_Impl.java:155) com.urbanairship.messagecenter.Inbox.refresh (Inbox.java:686) com.urbanairship.messagecenter.Inbox.updateEnabledState (Inbox.java:222) com.urbanairship.messagecenter.MessageCenter.updateInboxEnabledState (MessageCenter.java:186) com.urbanairship.messagecenter.MessageCenter.init (MessageCenter.java:173) com.urbanairship.UAirship.init (UAirship.java:800) com.urbanairship.UAirship.executeTakeOff (UAirship.java:422) com.urbanairship.UAirship.access$000 (UAirship.java:67) com.urbanairship.UAirship$2.run (UAirship.java:381) java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162) java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636) com.urbanairship.util.AirshipThreadFactory$1.run (AirshipThreadFactory.java:50) java.lang.Thread.run (Thread.java:764)

Version: 16.6.0

Captura de Tela 2022-06-29 às 13 16 45
halysongoncalves commented 2 years ago

@rlepinski

jyaganeh commented 2 years ago

Hi @halysongoncalves, sorry you ran into this. I'm looking into it now and will get back to you as soon as I can.

jyaganeh commented 2 years ago

@halysongoncalves We've got a fix for this up for PR internally, and are planning to push a patch release tomorrow. The fix will prevent this crash from happening on new upgrades and any existing installs that are experiencing the issue. I'll let you know when the new version is available.

Would you mind sharing the SDK version that you were on before updating to 16.6.0? I believe this crash is related to some changes from a while back that migrated the Message Center database to use Room, coupled with the way that Room validates existing tables during the process of opening them, but it'd be helpful to have another data point.

halysongoncalves commented 2 years ago

16.5.0

halysongoncalves commented 2 years ago

One option is to use fallbacktodestructivemigration

rlepinski commented 2 years ago

Fixed in 16.6.1

halysongoncalves commented 2 years ago

Thanks!