Why does the error "[ksp] java.lang.IllegalStateException: unexpected jvm signature V" occur when using Room with KSP and how can I solve it?
I am programming a small Counter app where the count should be stored in a Room database. I am using Kotlin, Jetpack Compose and Room Database with KSP. When I try to run the app the following error occurs: [ksp] java.lang.IllegalStateException: unexpected jvm signature V. When I comment out the code from CounterDatabase.kt the error disappear. Why does it occur and how do I solve it?
My files are:
build.gradle (Project)
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.compose) apply false
// Room
id("com.google.devtools.ksp") version "2.3.4" apply false
}
build.gradle (Module)
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.compose)
id("com.google.devtools.ksp")
}
android {
namespace = "com.example.counter"
compileSdk {
version = release(36) {
minorApiLevel = 1
}
}
defaultConfig {
applicationId = "com.example.counter"
minSdk = 24
targetSdk = 36
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
buildFeatures {
compose = true
}
}
dependencies {
// Room
implementation(libs.androidx.room.runtime)
ksp(libs.androidx.room.compiler)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.graphics)
implementation(libs.androidx.compose.ui.tooling.preview)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.lifecycle.viewmodel.compose)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
debugImplementation(libs.androidx.compose.ui.tooling)
debugImplementation(libs.androidx.compose.ui.test.manifest)
}
libs.versions.toml
[versions]
agp = "9.2.0"
coreKtx = "1.10.1"
junit = "4.13.2"
junitVersion = "1.1.5"
espressoCore = "3.5.1"
lifecycleRuntimeKtx = "2.6.1"
activityCompose = "1.8.0"
kotlin = "2.2.10"
composeBom = "2026.02.01"
lifecycleViewmodelCompose = "2.10.0"
roomCompiler = "2.5.0"
roomRuntime = "2.8.4"
roomCompilerVersion = "2.8.4"
[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycleViewmodelCompose" }
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "roomCompiler" }
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "roomRuntime" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" }
androidx-compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
androidx-compose-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "roomCompilerVersion" }
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
CounterDatabase.kt
In this file I do also receive the following two errors:
Function "counterDataAccessObject" is never used
Function "getDatabase" is never used
package com.example.counter.counter.database
import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
@Database(
entities = [CounterEntity::class],
version = 1
)
abstract class CounterDatabase : RoomDatabase() {
abstract fun counterDataAccessObject() : CounterDataAccessObject
companion object {
@Volatile
private var INSTANCE: CounterDatabase? = null
fun getDatabase(context: Context): CounterDatabase {
return INSTANCE ?: synchronized(this) {
val instance = Room.databaseBuilder(
context.applicationContext,
CounterDatabase::class.java,
"CounterDatabase"
).build()
INSTANCE = instance
instance
}
}
}
}
Dao file
package com.example.counter.counter.database
import androidx.room.Dao
import androidx.room.Query
@Dao
interface CounterDataAccessObject {
@Query("SELECT count FROM CounterEntity WHERE id = :id")
suspend fun getCount(id: Int): Int?
@Query("UPDATE CounterEntity SET count = count + 1 WHERE id = :id")
suspend fun incrementCount(id: Int)
@Query("UPDATE CounterEntity SET count = count - 1 WHERE id = :id")
suspend fun decrementCount(id: Int)
}
Entity file
package com.example.counter.counter.database
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity
data class CounterEntity(
@PrimaryKey(autoGenerate = true) val id: Int = 0,
val count: Int)
You are mixing Room artifacts of different versions. That is bound to result in incompatibilities.
In your version catalog, you have these three versions defined:
roomCompiler = "2.5.0" roomRuntime = "2.8.4" roomCompilerVersion = "2.8.4"
Replace them with only one version definition:
room = "2.8.4"
Update the libraries androidx-room-compiler and androidx-room-runtime to use that instead.
You also have the redundant library room-compiler defined in the version catalog. Remove it, it isn't even used anywhere.
After a Gradle sync, your app should be able to be built again.