Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!