Room Implementation using version catalogs
/ 1 min read
Table of Contents
I encountered this error, after going through the Room tutorial. It seems, there are a lot of gradle plugins needed to make it work.
FATAL EXCEPTION: mainProcess: ph.onlinejobs.OnlineJobs, PID: 3602 java.lang.RuntimeException: Cannot find implementation for ph.onlinejobs.onlinejobs.database.OnlineJobsDatabase. OnlineJobsDatabase_Impl does not exist at androidx.room.Room.getGeneratedImplementation(Room.kt:58) at androidx.room.RoomDatabase$Builder.build(RoomDatabase.kt:1351)My initial libs.versions.toml looks like the one below
[versions]room = "2.6.1"
[libraries]room = { module = "androidx.room:room-runtime", version.ref = "room" }and my module-level gradle file
dependencies { implementation(libs.room)}KSP Plugin
Since I am using Kotlin, I need to install KSP Plugin
[versions]ksp = "2.1.10-1.0.31"
[plugins]ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }Top-level build.gradle.kts
plugins { alias(libs.plugins.ksp) apply false}Module-level build.gradle.kts
plugins { id(libs.plugins.ksp.get().pluginId)}Add missing plugins
[libraries]room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }Then, the build.gradle.kts should look like
implementation(libs.room)implementation(libs.room.ktx)ksp(libs.room.compiler)Then it should now fixed the runtime error.