Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

134
Vistas
Not sure how to convert a Cursor to this method's return type after Kotlin update to 1.6.0

I was using Android Room library in my project to manipulate data from my SQLite database and everything was working fine in previous Kotlin version (1.5.31). Here is a sample of my DAO:

@Dao
interface ServersDao {

    @Query("SELECT * FROM servers ORDER BY connectedDevices, ping ASC LIMIT 1")
    suspend fun getLeastLoadedServer(): Server

    @Query("SELECT * FROM servers ORDER BY ping, connectedDevices ASC LIMIT 1")
    suspend fun getNearestServer(): Server
}

After updating Kotlin to version 1.6.0, my code couldn't compile anymore, and I am receiving this error:

error: Not sure how to convert a Cursor to this method's return type (java.lang.Object). public abstract java.lang.Object getLeastLoadedServer(@org.jetbrains.annotations.NotNull()

After some searching, I read that it was because of suspending functions, so I removed suspend keyword from my DAO, and I started getting the obvious error:

java.lang.IllegalStateException: Cannot access database on the main thread since it may potentially lock the UI for a long period of time.

Even if I was calling those function from a IO coroutine.

I also read through the change log of Kotlin 1.6.0, that did not help much.

Any help is appreciated, thanks.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Using Android Room 2.4.0 will solve the issue.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda