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

1.3K
Vistas
how to fix unresolved reference lifecycleScope?

Trying to build a simple example that uses kotlin coroutines in an activity:

   lifecycleScope.launch {
             val result = httpGet("http://hmkcode-api.appspot.com/rest/api/hello/Android")
              textView.setText(result)
   }

Can't get rid of error "unresolved reference lifecycleScope"

Relevant part of gradle file:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'



dependencies {

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-rx2:1.3.2"

def androidArchVersion = '1.1.1'
implementation "android.arch.lifecycle:viewmodel:$androidArchVersion"
implementation "android.arch.lifecycle:livedata:$androidArchVersion"
annotationProcessor "android.arch.lifecycle:compiler:$androidArchVersion"
testImplementation "android.arch.core:core-testing:$androidArchVersion"
implementation "android.arch.lifecycle:extensions:$androidArchVersion"
}

kotlinOptions {
    jvmTarget = '1.8'
    apiVersion = '1.3'
    languageVersion = '1.3'
}

}

over 4 years ago · Hanz Gallego
2 Respuestas
Responde la pregunta

0

As per the Lifecycle KTX documentation, you must include the lifecycle-runtime-ktx artifact if you want Coroutine specific extensions.

Note that lifecycle-runtime-ktx was only introduced in Lifecycle 2.2.0, so you'll need to Migrate to AndroidX, then upgrade to Lifecycle 2.2.0 if you want to use that functionality.

over 4 years ago · Hanz Gallego Denunciar

0

Late response here but I also faced this issue and finally managed to resolve it by changing the inherited Android Activity to an AppCompatActivity.

over 4 years ago · Hanz Gallego 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