Hello Everyone, i need help with resolving error r...
# room
a
Hello Everyone, i need help with resolving error related to room database. i'm using room v2.5.2
Copy code
val room_version = "2.5.2"
    implementation("androidx.room:room-ktx:$room_version")
    kapt("androidx.room:room-compiler:$room_version")
and this is how my dao file looks like.
Copy code
interface CurrencyDao {

    @Insert
    fun insertCurrency(currency: Currency): Long

    @Query("SELECT * FROM Currency")
    suspend fun fetchCurrencies(): List<Currency>
}
and i'm getting below error on build. i saw top slackoverflow results for above. but it was not helpful.
Copy code
error: Not sure how to convert a Cursor to this method's return type (java.lang.Object).
    public abstract java.lang.Object fetchCurrencies(@org.jetbrains.annotations.NotNull
s
Maybe try to add
implementation("androidx.room:room-runtime:$room_version")
as well.
c
@Abhi Could you solve this in the meantime? @s3rius I’m facing the same issue, although I’m having room-runtime included. I think, it is related to TypeConverters. https://stackoverflow.com/questions/46445964/room-not-sure-how-to-convert-a-cursor-to-this-methods-return-type-which-meth states that moving from kapt to ksp should resolve the issue. But is it the only resolution?
s
We have several projects using Kotlin 1.8 and Room using kapt with no issues. It could be an issue with Kotlin 1.9 and kapt, possibly. I can't verify it but I've have a couple of breakages going from 1.8.22 to 1.9.x so I wouldn't rule it out. But that's a shot in the dark.
c
I migrated from KAPT to KSP and now it works. Using Room 2.5.2 and Koltin 1.9.10.
a
Sorry, I was offline for last 2 weeks. it worked for me when i updated room version to
2.6.0-beta01
👍 1