https://kotlinlang.org logo
#android
Title
# android
j

Joe Altidore

07/05/2022, 8:20 AM
Hello guys! I am encountering an error with Room Database when using Kotlin 1.7.0 but if I downgrade my Kotlin version to 1.6.21, everything works fine. This is the error:
Copy code
error: Query method parameters should either be a type that can be converted into a database column or a List / Array that contains such type. You can consider adding a Type Adapter for this.
    kotlin.coroutines.Continuation<? super java.lang.Integer> continuation);
and this is the DAO Query throwing the error:
@Query("""
SELECT COUNT(*) FROM enrolment
""")
suspend fun getEnrolmentCount(): Int?
k

Ken Shackleton

07/05/2022, 8:25 AM
Update your Room dependency too
☝️ 1
k

Krystian Demidiuk

07/05/2022, 8:26 AM
j

Joe Altidore

07/05/2022, 8:31 AM
My room version is the latest.
Copy code
implementation "androidx.room:room-runtime:2.4.2"
kapt "androidx.room:room-compiler:2.4.2"
k

Krystian Demidiuk

07/05/2022, 9:22 AM
Correct me if I’m wrong, but is nullable integer necessary here as you should receive 0 if the table is empty? Maybe try using non-nullable integer as the return type.
j

Joe Altidore

07/05/2022, 11:48 AM
@Krystian Demidiuk I have tried that but it is not the issue a the moment
w

Wesley Jonathan Marcolino

07/05/2022, 4:30 PM
@Joe Altidore Updating to
2.5.0-alpha02
fixed the issue for me.
j

Joe Altidore

07/05/2022, 5:45 PM
@Wesley Jonathan Marcolino Thanks for the solution. It worked for me.
🙌 1
Thanks everyone for your contributions