Why did my Android app freeze?

Kyrylo Silin
Kyrylo Silin
Telebugs founder

I put a “Block main thread” button in a little Android app. Its handler puts the main thread to sleep for twenty seconds. I tapped it on a Samsung phone running Android 13, and the screen stopped responding.

The Telebugs Android test app on a Samsung phone. Its four buttons read Handled exception, Java crash, Native crash, and Block main thread.

The test app on my Samsung phone. The bottom button triggers the freeze. View the full photo.

When I opened the app again, the Sentry Android SDK sent a report to my Telebugs installation. The main thread’s stack pointed to MainActivity.kt:27. That was my button.

Telebugs 2.3 brings Android error tracking to your own server. You can follow an exception back to the Kotlin or Java that threw it, see what the app was doing when it froze, and trace crashes into native libraries.

Where the screen stopped

Android apps use the main thread to draw the screen and handle taps. Keep it busy long enough and Android can report an Application Not Responding error, usually shortened to ANR. The app can still be running when this happens.

Main-thread stack from the Android freeze showing the app’s button handler at MainActivity.kt line 27.

The button handler in the report from the Samsung phone. Line 27 calls Thread.sleep(20000).

In a real app, the same frame might point to a database query in a tap handler. Seeing which call ties up the main thread gives you somewhere to start, even when you can’t reproduce the freeze on your own phone.

I can also ask a coding assistant connected to Telebugs through MCP, “Which call blocked the main thread?” It can read the same MainActivity.kt:27 frame I saw in the browser. If you fetch the report through the REST API, you get that source location alongside the frames the SDK sent. See MCP report details and the REST report endpoint.

Same version, different line

Ordinary Kotlin and Java exceptions also get readable backtraces. There’s one wrinkle with release builds. Android’s R8 optimizer can shorten the class and method names and move code around. Gradle produces a mapping file that tells Telebugs how to read that particular build.

I installed two builds of the test app with the same version name and version code. Both reported the same Kotlin exception. With their respective mappings, Telebugs showed FixtureFailure.fail at MainActivity.kt:10 in the first build and MainActivity.kt:11 in the second. Picking a file by version number alone would have sent me to the wrong line in one of them.

The Sentry Android Gradle plugin can upload the right mapping as part of each release build. Enable its source bundle upload as well if you want to read the surrounding Kotlin or Java code in the report. If a crash gets there first, uploading the matching files fills in the existing report.

When a library crashes

A Kotlin app can call a library written in C or C++. Think of an image decoder shipped by a dependency. A crash inside it can leave you with a memory address where you expected a method name. This is where Android’s native debug symbols come in.

On the same phone I triggered a crash in a small C++ test library. With the symbols from that build, Telebugs pointed to fixture.cpp:5. If all your code runs in Kotlin or Java, the mapping and source bundle are all you need for those frames.

Connect your Android app

If you already use the Sentry Android SDK, keep your capture calls. Point the SDK at your Android project’s Telebugs DSN and configure the Gradle uploader with the same project on your server. You can check delivery with a handled exception before you cut the next build.

The Android setup guide has the manifest entry, Gradle settings and a first test. For an overview of what you’ll see in a report, take the Android crash reporting tour.