My DB was all right before it, I migrated from KAPT to KSP as follows documentation (https://developer.android.com/build/migrate-to-ksp), it worked fine for Hilt library, but when I change Room library it leads to RuntimeException, couldn't find any clues on internet neither related problems like this, what am I missing here?
FATAL EXCEPTION: pool-36-thread-2
Process: com.mypackage.myapp, PID: 3103
java.lang.RuntimeException: Cannot find implementation for com.mypackage.myapp.backend.databasehits.HitsDatabase. HitsDatabase_Impl does not exist
at androidx.room.Room.getGeneratedImplementation(Room.kt:58)
at androidx.room.RoomDatabase$Builder.build(RoomDatabase.kt:1357)
at com.mypackage.myapp.backend.databasehits.HitsDatabase$Companion.getInstance(HitsDatabase.kt:49)
at com.mypackage.myapp.backend.helper.SongHitHelper.getDb(SongHitHelper.kt:12)
at com.mypackage.myapp.backend.helper.SongHitHelper.access$getDb(SongHitHelper.kt:10)
at com.mypackage.myapp.backend.helper.SongHitHelper$getAll$1.invoke(SongHitHelper.kt:16)
at com.mypackage.myapp.backend.helper.SongHitHelper$getAll$1.invoke(SongHitHelper.kt:15)
at com.mypackage.myapp.backend.database.QueryExecutor.executeSync(QueryExecutor.kt:43)
at com.mypackage.myapp.backend.database.DbCall.executeSync(DbCall.kt:27)
at com.mypackage.myapp.backend.database.DbCall.executeAsync$lambda$3(DbCall.kt:90)
at com.mypackage.myapp.backend.database.DbCall.$r8$lambda$XterYYUlFvZeosmE2W9FxI8ZDDY(Unknown Source:0)
at com.mypackage.myapp.backend.database.DbCall$$ExternalSyntheticLambda0.run(Unknown Source:4)
build.gradle (Project level)
buildscript{
ext.kotlin_version = '1.8.10'
}
...
plugins {
id 'com.google.devtools.ksp' version '1.8.10-1.0.9'
}
...
build.gradle (app Module)
plugins {
...
id 'com.google.devtools.ksp'
...
}
...
dependencies {
// Room
implementation "androidx.room:room-runtime:${versions.room}"
ksp "androidx.room:room-compiler:${versions.room}"
...
}
I tryed changing the configuration, changing versions, looking on documentation but found nothing.
Adding implementation "androidx.room:room-ktx:${versions.room}"
or changing basically anything causes build to fail:
> Task :app:kspDebugKotlin
'compileDebugJavaWithJavac' task (current target is 11) and 'kspDebugKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
By default will become an error since Gradle 8.0+! Read more: https://kotl.in/gradle/jvm/target-validation
Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain
w: [ksp] /home/gelson/StudioProjects/AndroidL/MyApp/app/src/main/java/com/mypackage/backend/databasehits/HitsDatabase.kt:19: Schema export directory is not provided to the annotation processor so we cannot export the schema. You can either provide `room.schemaLocation` annotation processor argument OR set exportSchema to false.
e: [ksp] /home/gelson/StudioProjects/AndroidL/MyApp/app/src/main/java/com/mypackage/backend/models/User.kt:5: [MissingType]: Element 'com.mypackage.backend.models.User' references a type that is not present
e: Error occurred in KSP, check log for detail
> Task :app:kspDebugKotlin FAILED
[ksp] /home/gelson/StudioProjects/AndroidL/MyApp/app/src/main/java/com/mypackage/backend/databasehits/HitsDatabase.kt:19: Schema export directory is not provided to the annotation processor so we cannot export the schema. You can either provide `room.schemaLocation` annotation processor argument OR set exportSchema to false.
[ksp] /home/gelson/StudioProjects/AndroidL/MyApp/app/src/main/java/com/mypackage/backend/models/User.kt:5: [MissingType]: Element 'com.mypackage.backend.models.User' references a type that is not present
Turns out the problem was with a generated proto file that idk why (after changing to KSP) wasn't being generated before the database and then the system couldn't find a reference to proto file being used inside a bean class thats required for the database... I solved removing the use of that proto file that wasn't very important for the class.