What an ANR is

Android records an ANR when the app’s main thread cannot process an incoming event within the
allotted time:

  • Input event (a tap or a swipe) — a 5 second timeout
  • Broadcast receiver — a 10 second timeout
  • Service foreground start — a 20 second timeout

After the timeout the system shows the user a dialogue with a choice: wait, or force-close the app.
Most people choose to close it.

The main causes of ANRs in e-commerce apps

Network calls on the main thread — by far the most common cause. A request to the
recommendations, catalogue or authentication API executed synchronously on the UI thread blocks it
for the entire time the server takes to answer.

Heavy database work — synchronous SQLite or Room queries on the UI thread against a large
dataset such as order history or a catalogue cache.

Deadlock — two threads waiting on each other’s locks, blocking the main thread in the process.

SDK initialisation — some third-party SDKs perform disk or network operations synchronously
during initialisation; calling init() on the main thread then produces an ANR.

Impact on metrics and Google Play

Google Play tracks ANR rate through Android Vitals. The threshold is 0.47% of bad sessions,
meaning sessions with at least one ANR. Above it:

  • The app is flagged as poorly behaved inside Google’s systems
  • Organic visibility in Play Store search can fall
  • The Play Console displays a warning

For e-commerce, losing organic reach in the Play Store is a direct hit to installs.

How to fix ANRs

  1. Move all IO to background threads — Kotlin Coroutines, RxJava, ExecutorService
  2. Audit SDKs at start-up — check that init() does not block the main thread
  3. StrictMode in debug builds — it automatically detects main-thread operations that belong in
    the background
  4. Profiling in the Android Studio Profiler — find exactly where the main thread is busy for
    longer than it should be

Tip: when integrating a new SDK into an e-commerce app, always run it with StrictMode
enabled. Most ANR problems surface exactly this way — before they reach production.