无法在Room dao界面中使用Completable [英] Unable to use Completable in Room dao interface
本文介绍了无法在Room dao界面中使用Completable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在@Insert
注释方法的Dao类中使用Completable
,但是在尝试编译项目时,出现此错误:
I'm trying to use Completable
in Dao class on @Insert
annotated methods but when tried to compile the project, I've got this error:
error: Methods annotated with @Insert can return either void, long, Long, long[], Long[] or List<Long>.
public abstract io.reactivex.Completable insert(@org.jetbrains.annotations.NotNull()
这是我的相关代码:
@Insert
fun insert(kanal: Kanal): Completable
@Update
fun update(kanal: Kanal): Completable
@Delete
fun delete(kanal: Kanal): Completable
我的依赖项:
def room_version = "1.1.1"
implementation "android.arch.persistence.room:runtime:$room_version"
kapt "android.arch.persistence.room:compiler:$room_version"
implementation "android.arch.persistence.room:rxjava2:$room_version"
implementation 'io.reactivex.rxjava2:rxkotlin:2.2.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
根据此链接,它受支持按房间.
According to this link it's supported by Room.
推荐答案
@ Insert,@ Update和@Delete方法:Room 2.1.0和更高版本支持 返回类型为Completable,Single和Maybe的值.
@Insert, @Update, and @Delete methods: Room 2.1.0 and higher supports return values of type Completable, Single, and Maybe.
将您的房间从1.1.1
更新到2.1.0
或更高,它将可以正常工作.
Update your room from 1.1.1
to 2.1.0
or higher and it will work.
这篇关于无法在Room dao界面中使用Completable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文