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()
Here my related codes:
@Insert
fun insert(kanal: Kanal): Completable
@Update
fun update(kanal: Kanal): Completable
@Delete
fun delete(kanal: Kanal): Completable
And my dependencies:
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, 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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With