Unable to use Completable in Room dao interface
@Insert, @Update, and @Delete methods: Room 2.1.0 and higher supports return values of type Completable, Single, and Maybe.
Update your room from 1.1.1
to 2.1.0
or higher and it will work.
Completable isn't working with @Insert
in 1.1.1 version of Room. You have to use 2.1.0 version or higher which is only available in Android X.
Make sure to use these dependencies instead of regular android.arch.persistence.room
:
def room_version = "2.2.0-alpha02"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version" // For Java use annotationProcessor instead of kapt
implementation "androidx.room:room-rxjava2:$room_version"
testImplementation "androidx.room:room-testing:$room_version"
Here's the link that provides all of the Android X dependencies of Room.
if you dont want to update the Room's Version, you can try to make a Completable return like this:
fun insertSomthing():Completable{
return Completable.fromAction{
insert(kanal: Kanal)
}.subscribeOn(Schedulers.io())
}