Fixed
Status Update
Comments
da...@google.com <da...@google.com> #2
Also noticed that crash happens ~7-8 times per user.
da...@google.com <da...@google.com> #3
It looks like Room 2.1.0 is not using androidx.sqlite:sqlite-framework:2.0.1 which should contain a fix for the situation you are just describing. The snippet of code you pasted for getWrappedDb() is different than what is in the head of the repo. See: https://android.googlesource.com/platform/frameworks/support/+/androidx-master-dev/persistence/db-framework/src/main/java/androidx/sqlite/db/framework/FrameworkSQLiteOpenHelper.java#152
xu...@gmail.com <xu...@gmail.com> #4
This is a proper fix IMO. However, I can't find the package in http://maven.google.com/androidx/ . There I found only 2.0.0. Where else should I look? Also, the latest room 2.1.0-alpha4 does not include this version as well.
ro...@rockspin.co.uk <ro...@rockspin.co.uk> #5
It seems sqlite-framework:2.0.1 never made it to maven.google.com , we'll release it soon along with Room 2.1.0-alpha05 which should correctly depend on it. Sorry for the inconvenience.
ap...@google.com <ap...@google.com> #6
Thanks! I will definitely try the newest room version.
However, more I look at the code, more I believe the problem is elsewhere. If the migration fails, there will be no `SQLiteDatabase` and no `getWrappedDb(db)`. According to the code of `SQLiteOpenHelper`, there should be only one query before migration. The list of queries should be:
PRAGMA user_version;
DROP TABLE IF EXISTS `tracking_events` <--- this fails due closed database
DROP TABLE IF EXISTS `items` <-- never happens
More findings caught by my eye:
- I tried to make sure all DAO queries happen on a single thread. No success.
- The crash happens on a small number of users, but users get many crashes. I am afraid the user is unable to launch the app.
- Most crashes come from Samsung devices. But `SQLiteOpenHelper` class were not changed. All lines of stacktrace matches.
- `SQLiteOpenHelper` was constructed only once for `vinted_database.db`. However, meminfo shows something I don't understand:
DATABASES
pgsz dbsz Lookaside(b) cache Dbname
4 512 61 104/135/8 /data/user/0/lt.ito.md/databases/vinted_database.db
4 8 0/0/0 (attached) temp
4 512 25 35/14/2 /data/user/0/lt.ito.md/databases/vinted_database.db (3)
Looks like database was opened two times. There was opened more databases in my app, but no one appears in this list.
What else I could check?
However, more I look at the code, more I believe the problem is elsewhere. If the migration fails, there will be no `SQLiteDatabase` and no `getWrappedDb(db)`. According to the code of `SQLiteOpenHelper`, there should be only one query before migration. The list of queries should be:
PRAGMA user_version;
DROP TABLE IF EXISTS `tracking_events` <--- this fails due closed database
DROP TABLE IF EXISTS `items` <-- never happens
More findings caught by my eye:
- I tried to make sure all DAO queries happen on a single thread. No success.
- The crash happens on a small number of users, but users get many crashes. I am afraid the user is unable to launch the app.
- Most crashes come from Samsung devices. But `SQLiteOpenHelper` class were not changed. All lines of stacktrace matches.
- `SQLiteOpenHelper` was constructed only once for `vinted_database.db`. However, meminfo shows something I don't understand:
DATABASES
pgsz dbsz Lookaside(b) cache Dbname
4 512 61 104/135/8 /data/user/0/
4 8 0/0/0 (attached) temp
4 512 25 35/14/2 /data/user/0/
Looks like database was opened two times. There was opened more databases in my app, but no one appears in this list.
What else I could check?
da...@google.com <da...@google.com>
da...@google.com <da...@google.com>
le...@gmail.com <le...@gmail.com> #7
This type of behavior can also be seen when the corrupted database recovery mechanism is not correctly performed. Something that sqlite-framework:2.0.1 also fixed over its previous version.
See this patch and specifically the test in it:https://android.googlesource.com/platform/frameworks/support/+/611c90a4711670f8fe0d66ff2eaa8cb0266422d5
When the DB is corrupted (outside your control, and very little to do really) then the DB is immediately closed in hopes of creating a new DB (and a new object). What ends up happening is the corrupted object is still used causing the first db operation to fail (in this case a migration or that DROP TABLE IF EXISTS).
See this patch and specifically the test in it:
When the DB is corrupted (outside your control, and very little to do really) then the DB is immediately closed in hopes of creating a new DB (and a new object). What ends up happening is the corrupted object is still used causing the first db operation to fail (in this case a migration or that DROP TABLE IF EXISTS).
da...@google.com <da...@google.com> #8
That makes sense. I will update the app as soon as the new Room will be released and let you know if it helps.
mx...@gmail.com <mx...@gmail.com> #9
For those who are facing this problem, you can simply add this line before the room-compiler
as a workaround now:
+kapt("org.xerial:sqlite-jdbc:3.34.0")
kapt("androidx.room:room-compiler:2.3.0-beta01")
ce...@gmail.com <ce...@gmail.com> #10
If the mentioned workarounds are not working, I recommend using this workaround instead, adding it to the root build.gradle. This will force using the given dependency in the whole project:
allprojects {
configurations.all {
resolutionStrategy {
force 'org.xerial:sqlite-jdbc:3.34.0'
}
}
}
za...@gmail.com <za...@gmail.com> #11
You should use configureEach instead of all, FYI!
ro...@gmail.com <ro...@gmail.com> #12
As the "org.xerial:sqlite-jdbc:3.32.3.3" does not have the "org.xerial:sqlite-jdbc:3.34"'s issue https://github.com/xerial/sqlite-jdbc/pull/578 , can we update the depency to "org.xerial:sqlite-jdbc:3.32.3.3" first.
da...@google.com <da...@google.com>
za...@gmail.com <za...@gmail.com> #13
Just a note for others - fixed *in room 2.4.0-alpha03
zh...@gmail.com <zh...@gmail.com> #14
we need a patch version for 2.3.x
za...@gmail.com <za...@gmail.com> #15
You have a workaround for that
zh...@gmail.com <zh...@gmail.com> #16
why not release room 2.4.0, it's alpha until now!!!!!
za...@gmail.com <za...@gmail.com> #17
Please contain your hysteria, this is an issue tracker not a war zone.
On Thu, Sep 2, 2021 at 2:27 AM <buganizer-system@google.com> wrote:
On Thu, Sep 2, 2021 at 2:27 AM <buganizer-system@google.com> wrote:
[Deleted User] <[Deleted User]> #18
When using Room 2.4.0-beta01, our app compiles fine. When running on my Pixel device, I get a crash on startup
10-26 14:16:44.108 E/AndroidRuntime(26052): Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/sqlite/db/SupportSQLiteCompat$Api19Impl;
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.room.RoomDatabase$JournalMode.isLowRamDevice(RoomDatabase.java:755)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.room.RoomDatabase$JournalMode.resolve(RoomDatabase.java:746)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.room.RoomDatabase$Builder.build(RoomDatabase.java:1446)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.work.impl.WorkDatabase.create(WorkDatabase.java:155)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.work.impl.WorkManagerImpl.<init>(WorkManagerImpl.java:244)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.work.impl.WorkManagerImpl.<init>(WorkManagerImpl.java:219)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.work.impl.WorkManagerImpl.initialize(WorkManagerImpl.java:198)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.work.WorkManager.initialize(WorkManager.java:210)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.work.WorkManagerInitializer.create(WorkManagerInitializer.java:39)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.work.WorkManagerInitializer.create(WorkManagerInitializer.java:30)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:155)
10-26 14:16:44.108 E/AndroidRuntime(26052): Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/sqlite/db/SupportSQLiteCompat$Api19Impl;
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.room.RoomDatabase$JournalMode.isLowRamDevice(RoomDatabase.java:755)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.room.RoomDatabase$JournalMode.resolve(RoomDatabase.java:746)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.room.RoomDatabase$Builder.build(RoomDatabase.java:1446)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.work.impl.WorkDatabase.create(WorkDatabase.java:155)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.work.impl.WorkManagerImpl.<init>(WorkManagerImpl.java:244)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.work.impl.WorkManagerImpl.<init>(WorkManagerImpl.java:219)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.work.impl.WorkManagerImpl.initialize(WorkManagerImpl.java:198)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.work.WorkManager.initialize(WorkManager.java:210)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.work.WorkManagerInitializer.create(WorkManagerInitializer.java:39)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.work.WorkManagerInitializer.create(WorkManagerInitializer.java:30)
10-26 14:16:44.108 E/AndroidRuntime(26052): at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:155)
yb...@google.com <yb...@google.com> #19
#18, you might be hitting multi-dex issues. Do you have multi-dex enabled?
[Deleted User] <[Deleted User]> #20
Hi, sorry for the late response. We do have multi-dex enabled.
I created a dedicated issue to track this:https://issuetracker.google.com/issues/211668174
I created a dedicated issue to track this:
0....@gmail.com <0....@gmail.com> #22
after updating I now have got another error :
Caused by: java.lang.IllegalArgumentException: @androidx.room.Database does not define an element autoMigrations()
at com.google.auto.common.AnnotationMirrors.getAnnotationElementAndValue(AnnotationMirrors.java:134)
Caused by: java.lang.IllegalArgumentException: @androidx.room.Database does not define an element autoMigrations()
at com.google.auto.common.AnnotationMirrors.getAnnotationElementAndValue(AnnotationMirrors.java:134)
Description
Component used: Room
Version used: 2.2.5
Devices/Android versions reproduced on: Mac mini M1 chip
JDK8-arm64 is downloaded from Zulu Builds of OpenJDK
Gradle stacktrace: