Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Can you share your Gradle build file and how room-compiler
is being setup? The error is indicating that the Room processor likely did not run which in turns means the generated implementation of the database was not created and can't be found.
da...@google.com <da...@google.com> #3
This is my gradle file. I need to re -explain it runs well in Android, iOS, and Desktop's debug.It only crash when runRelease on desktop.
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidApplication)
alias(libs.plugins.composeMultiplatform)
alias(libs.plugins.composeCompiler)
alias(libs.plugins.kotlinCocoapods)
alias(libs.plugins.googleKsp)
alias(libs.plugins.kotlinSerialization)
alias(libs.plugins.androidxRoom)
}
kotlin {
androidTarget {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}
iosX64()
iosArm64()
iosSimulatorArm64()
cocoapods {
summary = "Some description for the Shared Module"
homepage = "Link to the Shared Module homepage"
version = "1.0"
ios.deploymentTarget = "13.0"
podfile = project.file("../iosApp/Podfile")
framework {
baseName = "ComposeApp"
isStatic = true
}
}
jvm("desktop")
sourceSets {
val desktopMain by getting
androidMain.dependencies {
implementation(compose.preview)
implementation(libs.androidx.activity.compose)
}
commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material3)
implementation(compose.ui)
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)
implementation(libs.androidx.lifecycle.viewmodel)
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.androidx.navigation)
// Serialization
implementation(libs.kotlinx.serialization.json)
// Room
implementation(libs.androidx.room.runtime)
implementation(libs.androidx.sqlite.bundled)
}
desktopMain.dependencies {
implementation(compose.desktop.currentOs)
implementation(libs.kotlinx.coroutines.swing)
}
}
}
android {
namespace = "xxx"
compileSdk = libs.versions.android.compileSdk.get().toInt()
defaultConfig {
applicationId = "xxx"
minSdk = libs.versions.android.minSdk.get().toInt()
targetSdk = libs.versions.android.targetSdk.get().toInt()
versionCode = 1
versionName = "1.0"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
dependencies {
debugImplementation(compose.uiTooling)
}
compose.desktop {
application {
mainClass = "xxx.MainKt"
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "xxx"
packageVersion = "1.0.0"
}
}
}
dependencies {
kspCommonMainMetadata(libs.koin.ksp.compiler)
listOf(
"kspAndroid",
"kspDesktop",
"kspIosX64",
"kspIosArm64",
"kspIosSimulatorArm64"
).forEach {
add(it, libs.androidx.room.compiler)
}
}
project.tasks.withType(KotlinCompilationTask::class.java).configureEach {
if (name != "kspCommonMainKotlinMetadata") {
dependsOn("kspCommonMainKotlinMetadata")
}
}
kotlin.sourceSets.commonMain {
kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin")
}
room {
schemaDirectory("$projectDir/schemas")
}
Description
Version used: 2.1.0
Devices/Android versions reproduced on: Galaxy J6, Android 9
Hi, I use Room in my app with 2 processes working, with multi-process invalidation tracking set up. I see this crash in my console (and I can't reproduce it on my devices):
Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'void androidx.room.IMultiInstanceInvalidationService.broadcastInvalidation(int, java.lang.String[])' on a null object reference
at androidx.room.MultiInstanceInvalidationClient$6.onInvalidated + 182(MultiInstanceInvalidationClient.java:182)
at androidx.room.InvalidationTracker$ObserverWrapper.notifyByTableInvalidStatus + 636(InvalidationTracker.java:636)
at androidx.room.InvalidationTracker$1.run + 408(InvalidationTracker.java:408)
at java.util.concurrent.ThreadPoolExecutor.runWorker + 1167(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run + 641(ThreadPoolExecutor.java:641)
at java.lang.Thread.run + 764(Thread.java:764)