Classify the timeout before changing code

An Application Not Responding report means Android did not receive a timely response for a particular operation; it is not the same event as a process crash. Start with the ANR type, app version, Android version, device, and user action. Input dispatch, a receiver, a service, and a job have different deadlines and call paths, so the component named in the report narrows the investigation.

A Play Console ANR cluster describes a population, while one device trace describes one process at one moment. Use both when available: group reports by stack, release, device, and Android version, then compare the affected cohorts instead of treating every report as one root cause.

Read the main thread together with threads it is waiting on

In the ANR trace or bug report, first find the main thread and identify whether it is running, waiting on a monitor, blocked in I/O, or making a synchronous call into another process. A stack frame identifies where the thread was observed, not necessarily the code that originally caused the delay.

If the main thread waits for a lock, inspect the thread that owns the lock and what that thread is doing. If it is waiting on Binder, investigate the remote service and the call path. If it is runnable but consuming CPU, capture a system trace around the slow interaction and correlate the main-thread timeline with worker threads and system scheduling.

Some device traces require elevated access or are not available from a production user report. When a trace cannot be pulled directly, use the bug report or diagnostic data available through the supported Android tooling rather than assuming that a local emulator reproduces the same state.

Use profiling tools to test the leading hypothesis

Reproduce the same screen transition, action, or background event in a profileable build. Android Studio system traces show thread activity and scheduling over time; StrictMode is useful during development for detecting accidental main-thread disk or network access, but it does not prove that CPU work, lock contention, or remote calls are harmless.

For a suspected slow operation, compare a trace from before and after the change. Move blocking I/O off the main thread, break up long computation, shorten lock-held work, or make lifecycle-bound work cancellable as appropriate to the evidence. Moving work to a worker is not sufficient if the main thread still synchronously waits for it.

Verify the fix against the original failure mode

  1. Run the exact interaction repeatedly on a representative device and Android version.
  2. Exercise slow storage, constrained CPU, lifecycle changes, and relevant process or service states.
  3. Confirm the UI remains responsive and that cancellation or retries do not duplicate work.
  4. Compare ANR clusters and rates by release and type after rollout; do not infer success from one local run.

A useful diagnosis explains which operation missed its deadline, why the main thread could not progress, and what evidence changed after the fix. Keep crash, ANR, and slow-frame metrics distinct because they describe different user-visible failures.

Official references