Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 604
Manoj Perumarath Avatar asked Feb 27 '19 12:02

Manoj Perumarath


1 Answers

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'
like image 90
Manoj Perumarath Avatar answered Sep 27 '22 17:09

Manoj Perumarath