Tlaster
02/14/2025, 7:11 AMjava.lang.NullPointerException: null cannot be cast to non-null type androidx.room.compiler.processing.XAnnotation when building iOS project after upgrading room to 2.7.0-beta01, but the Android project builds fine, full stack trace in thread.Bradleycorn
02/14/2025, 7:57 PMВасилий
02/19/2025, 1:51 PMcalidion
03/03/2025, 9:19 AMdata class ExamWithDates(
@Embedded val exam: Exam,
@Relation(
parentColumn = "id",
entityColumn = "id",
associateBy = Junction(
value = ExamDate::class,
parentColumn = "examId",
entityColumn = "dateId",
)
)
val dates: List<Date>
)
I need dates ordered by dateThomas Hormes
03/05/2025, 6:32 AM:database module where most Entities, Daos, etc. live.
However i now have a different module, say :test where I want to add another Entity that I can add to my @Database Declaration in the :database module.
Whenever I try, i get an error saying I need to add a migration. When I add a migration however, I get the following error (see 🧵 )Pablo
03/14/2025, 5:26 PMAhmed
03/16/2025, 3:16 PMPablo
03/16/2025, 4:01 PMNote: Automated Room migrations rely on the generated database schema for both the old and the new versions of the database. If exportSchema is set to false, or if you have not yet compiled the database with the new version number, then automated migrations fail.
Specifically the part on if you have not yet compiled the database with the new version number. What is refering to? maybe google is telling that we need to open the sqlite file with an external tool and edit the pragma user_version value? Is that mandatory to make room migrations work?Morgane Soula
03/18/2025, 4:02 PM[ksp] [MissingType]: Element 'com.msoula.hobbymatchmaker.core.database.dao.converters.Converters' references a type that is not present
My build.gradle (dao module - database is pretty similar)
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
`kotlin-multiplatform`
`android-library`
alias(libs.plugins.compose.compiler)
alias(libs.plugins.compose.multiplatform)
alias(libs.plugins.serialization)
alias(libs.plugins.room.multiplatform)
alias(libs.plugins.ksp)
}
kotlin {
applyDefaultHierarchyTemplate()
androidTarget {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
}
}
iosX64()
iosArm64()
iosSimulatorArm64()
sourceSets {
commonMain.dependencies {
implementation(compose.runtime)
implementation(libs.kotlinx.coroutines.kmp)
implementation(libs.kotlinx.serialization)
//
implementation(libs.room.common)
implementation(libs.room.runtime)
}
androidMain.dependencies {
// Room
implementation(libs.room.runtime.android)
}
}
}
room { schemaDirectory("$projectDir/schemas") }
android {
namespace = "com.msoula.hobbymatchmaker.core.database.dao"
compileSdk = AndroidConfig.COMPILE_SDK
compileOptions {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
defaultConfig {
minSdk = AndroidConfig.MIN_SDK
}
}
dependencies {
add("kspCommonMainMetadata", libs.room.compiler)
add("kspAndroid", libs.room.compiler)
add("kspIosX64", libs.room.compiler)
add("kspIosArm64", libs.room.compiler)
add("kspIosSimulatorArm64", libs.room.compiler)
}
And the converter class
class Converters {
val jsonParser = Json { encodeDefaults = true; ignoreUnknownKeys = true }
@TypeConverter
fun fromGenreStringList(genres: List<String>?): String? {
return genres?.joinToString(",")
}
@TypeConverter
fun toGenreStringList(data: String?): List<String>? {
return data?.split(",")?.map { it.trim() }
}
@TypeConverter
fun fromGenreList(genres: List<Genre>?): String? {
return genres?.let { jsonParser.encodeToString(it) }
}
@TypeConverter
fun toGenreList(genreString: String?): List<Genre> {
return genreString?.let { jsonParser.decodeFromString<List<Genre>>(it) } ?: emptyList()
}
@TypeConverter
fun fromActorList(actors: List<Actor>?): String? {
return actors?.let { jsonParser.encodeToString(it) }
}
@TypeConverter
fun toActorList(actorString: String?): List<Actor> {
return actorString?.let { jsonParser.decodeFromString<List<Actor>>(it) } ?: emptyList()
}
}Manoj Kumar
03/19/2025, 9:41 AMinternal fun getDatabaseBuilder(app: Application): RoomDatabase.Builder<MyDatabase> {
val passphrase: ByteArray = SQLiteDatabase.getBytes("temp_passphrase".toCharArray())
val factory = SupportFactory(passphrase)
val dbFile = app.getDatabasePath(KMPConstants.DB_FILE_NAME)
return Room.databaseBuilder<MyDatabase>(
context = app,
name = dbFile.absolutePath,
)
.openHelperFactory(factory)
}
How do I do it for iOS?Istvan Lorincz
03/21/2025, 3:58 PMkotlin.code.style=official
kotlin.daemon.jvmargs=-Xmx6g
#Gradle
org.gradle.jvmargs=-Xmx6g -Dfile.encoding=UTF-8 -XX:+UseG1GC
#Android
android.nonTransitiveRClass=true
android.useAndroidX=true
# Enable Gradle Daemon
org.gradle.daemon=true
# Enable Configure on demand
org.gradle.configureondemand=true
# Enable parallel builds
org.gradle.parallel=true
# Enable Build Cache
#android.enableBuildCache=true
# Enable simple gradle caching
org.gradle.caching=true
# Increase memory allotted to JVM
ksp.incremental=true
#
## Enable Kotlin Incremental Compilation
kotlin.incremental=true
kotlin.incremental.multiplatform=true
#
## Enable Configuration Cache
#org.gradle.configuration-cache=trueIstvan Lorincz
03/22/2025, 11:31 PMPablichjenkov
04/02/2025, 4:24 PMGrigory Panko
04/11/2025, 11:34 AM@Upsert and @Insert(onConflict = OnConflictStrategy.REPLACE). It seems to me that @Upsert should be more efficient (it was introduced more recently and has semantics of INSERT ... ON CONFLICT DO UPDATE within single query), while OnConflictStrategy.REPLACE looks like it will try to insert row in first query, and if it fails, run another query with update. But looking at the generated dao implementation, I see that OnConflictStrategy.REPLACE uses INSERT OR REPLACE INTO , while @Upsert has 2 separate INSERT and UPDATE queries. Does it mean that OnConflictStrategy.REPLACE should be more efficient when updating rows?alexhelder
05/12/2025, 12:57 AMFoos (from network) in Room. There can be some ‘local only’ state (like DownloadManager ID and favorite status) that also needs to be associated with each Foo. Would you put those ‘local state’ columns in the same Room table storing the Paged Foos, or do a 1:1 relationship with the paged Foo table and another table, like LocalFooState ?Olivier Patry
05/12/2025, 5:51 PM@Query(
"""
SELECT * FROM task
WHERE parent_list_local_id = :taskListLocalId
AND parent_local_id = :parentTaskLocalId
AND position <= :position
AND is_completed = false
ORDER BY position ASC
"""
)
suspend fun getTasksUpToPosition(taskListLocalId: Long, parentTaskLocalId: Long?, position: String): List<TaskEntity>
If I force parent_local_id IS NULL, it's ok
If I force parent_local_id = 0L, it's ok
But can't have both at the same time using (equivalent of = NULL)
I went for COALESCE(parent_local_id, -1) = COALESCE(:parentTaskLocalId, -1) for concision (knowing my ID is always positive)
I also made it work with an OR parent_local_id = :parentTaskLocalId OR (:parentTaskLocalId IS NULL AND parent_local_id IS NULL)
I was expecting the generator to deal with nullable parameter itself.
In the generated code, it deals with it, and use bindNull but nothing more fancy.
Do I miss something? Is it a requirement of Room somehow? Why? Would it be desirable to have it working?
(FTR, I'm using Room on desktop with SQLite Bundled)Altynbek Nurtaza
05/15/2025, 6:04 PMhafiz
05/17/2025, 1:58 AMUmesh Gupta
05/29/2025, 12:52 PMroom android, ios and desktop but app.cash.sqldelight for JS and Wasm . Need help with gradle how to handle NonJs and Js with ksp and room for nonJs and sqldelight {databases {}} for Js and WasmPablo
06/03/2025, 6:13 PMPablo
06/03/2025, 8:33 PMPre-package Database
The following APIs to create a RoomDatabase using an existing database (i.e. a pre-packaged database) are not available in common and are thus not available in other platforms other than Android. These APIs are:
RoomDatabase.Builder.createFromAsset
RoomDatabase.Builder.createFromFile
RoomDatabase.Builder.createFromInputStream
RoomDatabase.PrepackagedDatabaseCallback
We intend to add support for pre-packaged databases in a future version of Room.
Does this mean that if I have a .db file with content can't use it for populate the room database in Desktop etc... using Room multiplatform?Olivier Patry
06/12/2025, 7:51 PMimplementation(libs.androidx.room.common)
testImplementation(libs.androidx.room.runtime.jvm)
testImplementation(libs.androidx.sqlite.jvm)
testImplementation(libs.androidx.room.testing)
But the inMemoryDatabaseBuilder function references the Android Context, it comes from the Android runtime dependency despite not being referenced.
How could I manage to run Unit tests using Dao with in-memory DB on Jvm unit test with an Android library module?Taha
06/16/2025, 9:06 AMSuhaib Kazi
07/31/2025, 9:56 AM// Old
kotlin = "2.0.0"
devToolsKsp = "2.0.0-1.0.23"
// New
kotlin = "2.2.0"
devToolsKsp = "2.2.0-2.0.2"
Room's schema generator goes a bit bezerk and decides to remove some of my embedded objects and changes schema hash as well, which fails the integrity check.
And that too not on all embedded objects across my projects, only some of them?!
If i revert back, all seems to be A Okay!!!
Any clue what might be happening here?Sergi Mascaró
08/05/2025, 3:25 PM@Transaction in the right order to satisfy the FKs. That is:
1. insertA()
2. allB.foreach { insertB() }
3. allC.foreach { insertC() }
Now, after months of debugging what is going on, I noticed when adding query logging that sometimes a C will be inserted before all Bs have been inserted and cause a foreign key violation. I found out about deffered foreign keys and I was extremely happy, until I realized that it's broken and Google is not fixing it.
Any ideas or experiences? I'm quite lost, it shouldn't be a rare scenario...ptsiogas
09/04/2025, 10:42 AMMarv
10/14/2025, 4:00 PMON CONFLICT statement in room?
INSERT INTO X (a,b,c) VALUES (:x, :y, :z)
ON CONFLICT(X) DO UPDATE SET
a=excluded.a
WHERE excluded.b > X.b
works, but using multiple ON CONFLICT results in error.
The "spec" suggests you can have multiple ON CONFLICT in the statement and it works in sqlite3 command lineNathan Fallet
10/21/2025, 3:37 PMJan Skrasek
10/26/2025, 6:22 PMPablichjenkov
11/11/2025, 9:06 PM