Incorrect code generation from room @Query when using Flowable/Observable
Asked Answered
A

2

5

When trying to use RxJava with room, I am getting an error that the generated code is wrong. When returning a Single, it works fine. But when using flowable or observable its adding an extra boolean param to the generated method causing an error.

query

@Query("SELECT * FROM cards")
fun cardsStream(): Observable<List<Card>>

error

error: no suitable method found for createObservable(RoomDatabase,boolean,String[],<anonymous Callable<List<Card>>>)

the generated method. If I remove the false then it compiles. But obviously I cannot do that as this is generated code.

return RxRoom.createObservable(__db, false, new String[]{"cards"}, new Callable<List<Card>>() {
Amoy answered 11/4, 2019 at 1:55 Comment(0)
M
12

Replacing

implementation 'androidx.room:room-rxjava2:2.0.0'

with

 implementation 'androidx.room:room-rxjava2:2.2.2'

fixes it.

Mylander answered 22/4, 2019 at 3:40 Comment(0)
P
1

I also faced the same error but the problem in my case was that I was importing room libraries from AndroidX and the room-rxjava from the older appcompat type library. 🤦‍♂️

Pisciform answered 30/11, 2019 at 6:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.