Android ANRs: what they are, how to find and fix them
An ANR (Application Not Responding) is Android telling the user your app's main thread is blocked: most often it has not handled a touch or key event within 5 seconds. The cause is almost always work on the main thread: disk or database I/O, a long calculation, a slow binder call, or waiting on a lock another thread holds. Find the blocking frame in the main thread's stack in the ANR trace, move that work off the main thread, and watch your user-perceived ANR rate in Android vitals, where Google Play's bad behavior threshold is 0.47% of daily active users.
Steps
- Check which rate is highIn Android vitals, compare user-perceived ANR rate overall and per device model against the 0.47% and 8% thresholds.
- Get the main thread's stackOpen the ANR in Sentry or Play Console, or pull /data/anr files from a test device, and find the "main" thread.
- Classify the blockBlocked or waiting on a lock, Native in I/O, or Runnable in your own code: each points to a different fix.
- Find who holds the lockFor Blocked threads, follow "held by thread N" to the thread that owns the lock and fix what it does while holding it.
- Move the work and verifyMove I/O and heavy work off the main thread, ship, and watch the rate for the next release before calling it fixed.
When Android declares an ANR
Android's documentation lists the conditions that trigger an ANR. The timeouts are not all the same:
| Trigger | Limit |
|---|---|
| Input dispatching timed out (touch or key event not handled) | 5 seconds |
Service started with Context.startForegroundService doesn't call startForeground | 5 seconds |
BroadcastReceiver hasn't finished, app has an activity in the foreground | 10 seconds |
Service.onCreate and onStartCommand/onBind don't finish | "a few seconds" |
JobService.onStartJob/onStopJob don't return, or a user-initiated job doesn't call setNotification | "a few seconds" |
Only the first row is user-perceived in Play's terms. In the foreground the user sees the ANR dialog and can close the app. Background ANRs (for example a slow broadcast receiver) only show a dialog when Show all ANRs is on in Developer options, which is why many teams don't know they have them. For jobs, apps targeting Android 13 and lower get silent ANRs; from Android 14 they are reported to the app.
Android vitals: the 0.47% and 8% thresholds
Play Console's Android vitals tracks three rates, each as a share of daily active users (one user on one device on one day): ANR rate (any ANR), user-perceived ANR rate (currently only Input dispatching timed out), and multiple ANR rate (two or more ANRs).
User-perceived ANR rate is a core vital that affects how discoverable your app is on Google Play. As of November 2026 Play defines two bad behavior thresholds:
- Overall: at least 0.47% of daily active users experience a user-perceived ANR, across all device models. Above it, your app is likely to be less discoverable on all devices.
- Per device: at least 8% of daily users on a single device model. Above it, the app is likely to be less discoverable on those devices and a warning may be shown on your store listing.
The per-device threshold is the one that surprises teams: one cheap phone model with slow storage can cross 8% while your overall rate looks fine.
Causes, most common first
- I/O on the main thread.
SharedPreferencesreads, Room or SQLite queries, file reads while building the first screen. Fast on your test phone, seconds on a busy low-end device. - Lock contention. The main thread waits on a
synchronizedblock or lock while a background thread holds it during a long operation (a network call, a big write). - Slow broadcast receivers. Heavy work in
onReceive, or callinggoAsync()and never callingfinish()on thePendingResult. - Long calculations on the main thread. Parsing large JSON, sorting or filtering lists inside a composable that re-runs on every recomposition, image decoding.
- Synchronous binder calls to another process (a system service or another app) that is slow to answer.
- Deadlocks, where the main thread and another thread each hold what the other needs. These never recover on their own.
- Services and jobs that don't call
startForegroundor return fromonStartJobin time.
Read the ANR trace
Android writes thread dumps when an ANR happens: /data/anr/traces.txt on older releases, several /data/anr/anr_* files on newer ones. On an emulator or a rooted device:
adb root
adb shell ls /data/anr
adb pull /data/anr/<filename>On a normal phone, use adb bugreport or the Take bug report developer option. Go straight to the "main" thread and read its state and its top app frame. A typical lock-contention ANR looks like this (shortened):
"main" prio=5 tid=1 Blocked
at com.acme.web.data.SessionStore.current(SessionStore.kt:41)
- waiting to lock <0x0b7d1e2a> (a java.lang.Object) held by thread 23
at com.acme.web.ui.HomeActivity.onResume(HomeActivity.kt:88)
"SyncWorker" prio=5 tid=23 Native
at java.net.SocketInputStream.socketRead0(Native Method)
...
at com.acme.web.data.SessionStore.refresh(SessionStore.kt:63)
- locked <0x0b7d1e2a> (a java.lang.Object)Read it as: the main thread is Blocked waiting for a lock that thread 23 holds while it waits on the network. The fix is not in onResume; it is refresh() holding the lock across a network call. Other states to recognise: Runnable with your code on top means a long calculation; Native in a database or file call means main-thread I/O; a main thread idle in MessageQueue.nativePollOnce means the dump was taken after the block cleared, so look at other ANRs in the same group.
Fixes that hold
Move I/O out of the UI layer: run it in a ViewModel or repository on Dispatchers.IO and let the screen render state.
// Before: disk read on the main thread during onCreate
val token = prefs.getString("token", null)
// After
class HomeViewModel(private val repo: SessionRepository) : ViewModel() {
val token = flow { emit(repo.loadToken()) } // repo uses withContext(Dispatchers.IO)
.stateIn(viewModelScope, SharingStarted.Eagerly, null)
}Never hold a lock across I/O; take a snapshot under the lock and do the slow work outside it, or replace the lock with a coroutine Mutex, which suspends instead of blocking the main thread. Keep onReceive short and hand longer work to WorkManager. During development, turn on StrictMode to catch accidental main-thread disk and network access, and on Android 11+ read ApplicationExitInfo to see ANR exits from real users.
The mistake people make next: wrapping the slow call in a new thread but then calling .get() or runBlocking on the main thread to wait for it. That is the same ANR with an extra stack frame.
ANRs in Sentry
The Sentry Android SDK reports ANRs in two ways. On Android 11 and above it reads ApplicationExitInfo (v2), the same data source Google Play Console uses, so its numbers line up with vitals; these events carry mechanism:AppExitInfo. Below Android 11 it runs a watchdog thread (v1, mechanism:ANR) that fires when the main thread is blocked for more than five seconds; io.sentry.anr.timeout-interval-millis changes that interval. Set io.sentry.anr.enable to false in the manifest to turn detection off. Sentry does not report ANRs while the app is in debug mode, so test with a release build.
From SDK 8.35.0, ANRs whose stack traces contain only system frames get a static fingerprint, so they group together instead of flooding your issue list, and foreground and background ones are grouped separately. isAttachAnrThreadDump attaches the full thread dump (including held locks) from ApplicationExitInfo, which is exactly what you need to read lock-contention ANRs like the one above. See how to read a stack trace for the rest of the event.
Questions
What does "application not responding" mean on Android?
It means the app's main thread was blocked long enough that Android gave up waiting, usually 5 seconds for an input event. The user can wait or close the app from the dialog.
Is an ANR a crash?
No. The process is still alive and may recover, but if the user closes it from the dialog the app is killed. Play Console reports ANR rate separately from crash rate.
Why do I see ANRs in Play Console but never on my phone?
Background ANRs show no dialog unless Show all ANRs is enabled in Developer options, and many ANRs only happen on slower devices with busy storage or under heavy load.
Can a debug build show me ANRs in Sentry?
No. The Sentry Android SDK does not report ANRs when the app is in debug mode, so use a release build to test detection.
Sources
- ANRsdeveloper.android.com
- ANRs in Android vitalsdeveloper.android.com
- Application Not Responding (ANR)docs.sentry.io