In 2.1 Room added support for coroutines, but I can't get it working. It should be as easy as adding the dependency but somehow I'm overlooking something.
In my build.gradle I got the dependencies for coroutines, room and room-coroutines
dependencies {
def room_version = "2.2.0-beta01"
// Room components
implementation "android.arch.persistence.room:runtime:$room_version"
kapt "android.arch.persistence.room:compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
androidTestImplementation "android.arch.persistence.room:testing:$room_version"
def coroutines_version = "1.1.1"
// Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
}
I allready tryed resyncing gradle, cleaning and rebuilding the project.
In my Doa i have methods like the following
@Dao
interface PlanDao {
@Insert
suspend fun insertVerPlan(verPlan: SqlVerPlan)
}
When trying to build the project Room doesn't know how to handle the suspending functions and the following error occurs:
error: Type of the parameter must be a class annotated with @Entity or a collection/array of it.
kotlin.coroutines.Continuation<? super kotlin.Unit> p1);
^
error: Methods annotated with @Insert can return either void, long, Long, long[], Long[] or List<Long>.
public abstract java.lang.Object insertVerPlan(@org.jetbrains.annotations.NotNull()
^
I seriously don't know what I'm missing and I can't find anyone with the same problem since the new Room version.