The most actionable way to detect and fix Android ANRs

Duncan Hewett

For Android users, Application Not Responding (ANR) messages appear when an application “hangs” for a certain period of time. The user is truly stuck, and this unhelpful ANR message is anything but fun:

Android application not responding

Since the only two available options are to wait (not ideal) or to force-quit the app (definitely not ideal), an ANR error is, for all intents and purposes, just as bad as a full-on crash. Not surprisingly, many users consider ANRs to be grounds for a one-star rating and the impetus to go find a different app.

ANRs have nowhere to hide with Bugsnag

Bugsnag now provides full support for ANR error detection. (Hooray 🎉!)

With a full stack trace for ANRs, developers can quickly get to the code responsible for the app hanging. Bugsnag groups ANRs by cause, which makes it easy to prioritize the errors that are happening the most and determine which ones to fix.

Because Bugsnag is detecting ANR scenarios from INSIDE the code, more data is provided to developers, such as what happened in the run-up to the ANR, which users experienced the ANR, what experiments are enabled in the app, etc.

How exactly does this error detection for ANRs work?

  1. Bugsnag has a stack trace which shows the line of code that was running when the app froze and set off the ANR.
  2. If the app freezes multiple times on the same line, these errors are grouped into one error in Bugsnag with an indication of the number of occurrences.
  3. Using breadcrumbs, Bugsnag allows developers to see the actions a user was performing in the run-up to an ANR.
  4. Bugsnag also enables filtering by powerful pivots such as device make and model, Android version, or any other data to help reproduce and fix ANRs.

The information Bugsnag provides makes it a breeze to prioritize the ANR causes and determine what’s most important to fix first, as well as weigh the ANRs against other errors that are causing the app to crash.

Since ANRs count towards the app’s stability score, it’s also possible to track progress from release to release and see if new features are causing a higher rate of ANRs.

Releases dashboard stability

Why are ANRs such a pain for Android developers to address?

Perhaps the only thing more infuriating than the ANR user experience is the ANR developer experience. Often, there’s no insight provided into why ANR errors are occurring, and developers are limited in their capabilities to trace the source. Here’s why:

  1. Previously, the Google Play console was the only option for learning information about ANRs. Unfortunately, the console shows one piece of data: the “percentage of sessions with an ANR.” This data obviously isn’t actionable, nor does it explain why the ANR happened or which line of code is causing the error.
  2. Adding to the frustration, not all developers have access to the Play console. Most companies restrict it to a few team members because these users have full access to controls such as deletion or viewing how much money the app makes.
  3. Developers that do have access to the Play Console end up flipping back and forth between the two systems for stability data, which is time-consuming and inefficient. They view ANR data in the Play Console and detailed error data in, say, Bugsnag.

Thankfully, these ANR challenges become headaches of the past for Android developers who use Bugsnag.

How to get started

Ready to take control over ANRs?

Simply upgrade to the latest version of Bugsnag’s notifier libraries for your Android or React Native apps. ANRs will be detected automatically and start appearing in your Bugsnag dashboard.

Yep, it’s really that simple. Now go forth and conquer those pesky ANRs.

———

5/30/19 update: After this blog was posted, we made a change so that ANR detection is disabled by default. ANRs will not be detected automatically unless you enable ANR detection by setting the setDetectAnrs property to true. Please read our documentation for more information.

Share