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

主宰稳场 提交于 2019-12-08 07:51:13

问题


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

回答1:


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'


来源:https://stackoverflow.com/questions/54905252/android-room-insert-with-completable-not-working-methods-annotated-with-insert

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!