Android room insert with Completable not working? methods annotated with @insert can return either void,long?
Asked Answered
S

1

5

The versions i'm using are

implementation 'io.reactivex.rxjava2:rxjava:2.2.4'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
implementation 'android.arch.persistence.room:runtime:2.1.0-alpha04'
kapt 'android.arch.persistence.room:compiler:2.1.0-alpha04'
implementation 'android.arch.persistence.room:rxjava2:2.1.0-alpha04'

and the Dao is

@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertStore(stores: Stores): Completable
Sarcophagus answered 27/2, 2019 at 12:14 Comment(3)
What is the question?Oskar
I'm not able to set the return type of the function as CompletableSarcophagus
Completable has no return typeOskar
S
26

From this great article on medium, i found that;

starting with Room 2.1.0-alpha01, DAO methods annotated with @Insert, @Delete or @Update support Rx return types Completable, Single and Maybe

Even though i was using the latest version of the room i was having the issue,

implementation 'android.arch.persistence.room:runtime:2.1.0-alpha04'
kapt 'android.arch.persistence.room:compiler:2.1.0-alpha04'
implementation 'android.arch.persistence.room:rxjava2:2.1.0-alpha04'

I found the issue was occuring because of using androidx in my project, so in order to fix that i had to use androidx room components.

implementation 'androidx.room:room-runtime:2.1.0-alpha04'
kapt 'androidx.room:room-compiler:2.1.0-alpha04'
implementation 'androidx.room:room-rxjava2:2.1.0-alpha04'
Sarcophagus answered 1/3, 2019 at 4:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.