1

I'm using room database for android. It was working fine until I updated to Kotlin 1.7.0 recently. Now I get the following error:

Each bind variable in the query must have a matching method parameter. Cannot find method parameters for :limit, :offset.

Here is my dao:

@Query("SELECT * FROM eventdata ORDER BY id ASC LIMIT :limit OFFSET :offset")
fun allEvents(limit: Int, offset: Int): List<EventData>

Here my build.gradle

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
.
.
.
implementation "androidx.room:room-runtime:2.4.2"
kapt "androidx.room:room-compiler:2.4.2"

When I downgrade Kotlin to 1.6.21 it works fine. Is this a Kotlin Bug or am I doing something wrong?

modsfabio
  • 1,097
  • 1
  • 13
  • 29
  • Did you look at https://stackoverflow.com/questions/44206745/android-room-each-bind-variable-in-the-query-must-have-a-matching-method – MikkelT Jul 08 '22 at 08:36
  • Yes, the only thing that works is replacing the parameters with :arg0 and :arg1. But that doesn't seem right, also this seems to be a new problem with Kotlin 1.7.0 – modsfabio Jul 08 '22 at 08:42
  • If that's the case, I don't have a real fix. But you could put the arguments on a new line and comment //limit and //offset as as temp solution – MikkelT Jul 08 '22 at 08:51

1 Answers1

1

Upgrading "androidx.room..." to 2.4.3 worked for me