exponea / exponea-android-sdk

MIT License
17 stars 16 forks source link

Exponia DB migration exeption #76

Closed JustTrust closed 2 months ago

JustTrust commented 3 months ago
                                                   java.lang.IllegalStateException: A migration from 2 to 1 was required but not found. Please provide the necessary Migration path via RoomDatabase.Builder.addMigration(Migration ...) or allow for destructive migrations via one of the RoomDatabase.Builder.fallbackToDestructiveMigration* methods.
                                                    at androidx.room.RoomOpenHelper.onUpgrade(RoomOpenHelper.kt:110)
                                                    at androidx.room.RoomOpenHelper.onDowngrade(RoomOpenHelper.kt:123)
                                                    at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onDowngrade(FrameworkSQLiteOpenHelper.kt:277)
                                                    at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:413)
                                                    at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:316)
                                                    at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableOrReadableDatabase(FrameworkSQLiteOpenHelper.kt:232)
                                                    at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.innerGetDatabase(FrameworkSQLiteOpenHelper.kt:190)
                                                    at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getSupportDatabase(FrameworkSQLiteOpenHelper.kt:151)
                                                    at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.kt:104)
                                                    at androidx.room.RoomDatabase.inTransaction(RoomDatabase.kt:638)
                                                    at androidx.room.RoomDatabase.assertNotSuspendingTransaction(RoomDatabase.kt:457)
                                                    at com.exponea.sdk.database.ExportedEventDao_Impl.count(ExportedEventDao_Impl.java:309)
                                                    at com.exponea.sdk.database.ExponeaDatabase.count(ExponeaDatabase.kt:18)
                                                    at com.exponea.sdk.repository.EventRepositoryImpl.count(EventRepositoryImpl.kt:28)
                                                    at com.exponea.sdk.Exponea.initializeSdk(Exponea.kt:667)
                                                    at com.exponea.sdk.Exponea.init(Exponea.kt:324)
                                                    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1386)
                                                    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7504)
                                                    at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2416)
                                                    at android.os.Handler.dispatchMessage(Handler.java:107)
                                                    at android.os.Looper.loopOnce(Looper.java:232)
                                                    at android.os.Looper.loop(Looper.java:317)
                                                    at android.app.ActivityThread.main(ActivityThread.java:8705)
                                                    at java.lang.reflect.Method.invoke(Native Method)
                                                    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
adam1929 commented 2 months ago

Hi @JustTrust thank you for report. This problem could occur, if you initialized SDK with version 3.12.0+ and then SDK with older version is used. For example, you install newer app (with newer SDK) and then you reinstall app with older version (and older SDK). We are not plan to support downgrade-migration of database as it will lead to lost some data of course. Please feel free reopen task, if I understands your report incorrectly. Thank you