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

201
Vistas
Android App crashes without any Stack Trace Error

I just started with that new App and wanted to see if I get any Response by Retrofit and print it in a TextView.

But the App crashes without any Stack Trace so no Exception ... just nothing.

I have a Retrofit interface and a "Factory" that creates the Request everything runs in a different Thread via Kotlin Coroutine.

    class MainActivity : AppCompatActivity() {

    private lateinit var debugTextView: TextView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        debugTextView = findViewById(R.id.debugTextView)

        val service = RetrofitFactory.makeCarDataService()
        GlobalScope.launch(Dispatchers.Main) {
            val request = service.getData()

            val response = request.await()

            debugTextView.text =response.toString()

        }
    }
}

I would love to post an Error ... but there is none, everything should run perfectly :/

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

0

To use Dispatchers.Main we need to add the following line to the app's build.gradle file dependencies:

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.1'

Absence of that dependency could be the reason why the app crashes without any stack trace.

over 4 years ago · Santiago Trujillo Denunciar

0

Without stacktrace these are the possible problems:

service.getData()

can throw NullPointerException

debugTextView.text

can throw NullPointerException

response.toString()

can throw NullPointerException

over 4 years ago · Santiago Trujillo Denunciar

0

I'm not very familiar with the coroutines, but have you tried to use the main thread only while setting the text on the view? something like this:

val service = RetrofitFactory.makeCarDataService()
    GlobalScope.launch(Dispatchers.Default/*change here*/) {
        val request = service.getData()

        val response = request.await()
        /*change here*/
        withContext(Dispatchers.Main) {
            debugTextView.text = response.toString()
        }

    }
}
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