개발/안드로이드
Room의 DAO에서 suspend를 사용하려할 때 Not sure how to convert a Cursor to this method's return type
장모
2022. 6. 28. 04:38
@Dao
interface UserDao {
@Query("SELECT * FROM user")
suspend fun get(id: String): User
}
suspend를 사용해 컴파일하려고 보니 아래와 같은 오류가 발생한다.
Not sure how to convert a Cursor to this method's return type (java.lang.Object).
public abstract java.lang.Object get(@org.jetbrains.annotations.NotNull()
안드로이드 플러그인 1.7.0 버전과 Room 2.4.2 버전을 사용할 때 발생고, 플러그인 버전을 1.6.21로 변경해서 해결했다.
plugins {
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
...
}
혹은
buildscript {
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21'
...
}
}
안드로이드 플러그인 1.7.0과 Room 2.4.2를 같이 사용하려면 kapt를 ksp로 변경하면 된다.