Blog
SubscribeSubscribe

ANRs, or “application not responding” errors, are a critical issue facing Android developers, and despite the fact that mobile apps have become more technologically advanced over time, ANR rates have only increased. 

In fact, blank and unresponsive screens not only harm the user experience, they can also affect your app’s ranking on the Google Play Store. 

So what can developers do to solve ANR issues? Alon Dotan, Integration Engineer Team Leader at Unity, offers best practices for app developers to reduce their ANR rate. Let’s dive in. 

How developers can reduce their ANR rate

Over the years, I’ve seen first-hand how problematic code integrations can cause ANRs. This includes developers integrating their own code, third party code, and more. But by optimizing your code during integration, you can try to reduce your ANR rate. Here’s how:

1) Reduce the workload during the application pause (when the application moves to the background). During a pause period, you would generally store your app’s information in the server - for example, you would report a player’s position in the game so they can return to the same place they stopped. 

This workload, combined with other third party code creating its own workload, can overload the device’s resources - particularly the main thread. The main thread is the processor that affects an app’s user interface, and is often the main spot where ANRs are located. So any added workload on the main thread increases the potential for an ANR. 

During the application pause, make sure all the actions you’re taking are necessary - or try saving the user’s state in your local device memory. And, of course, see whether you can also complete these actions outside of the pause period. 

2) Segment devices that are likely to experience ANRs. Despite mobile devices getting more advanced, there are still devices in use with low processing power which are more likely to have ANRs.

As a developer, it’s critical to think about how each code integration could affect each of your devices, and choose carefully which integrations to run on older devices. 

3) Work with StrictMode to find ways you might be causing ANRs during integration. StrictMode is an Android tool that helps you find ways your actions might cause ANRs, like working on the main thread.

4) Confirm that the third party code (e.g. SDKs) you’re working with are the most updated versions. Using some older versions might present ANR issues.

5) Add an ANR watchdog, a component that reports ANRs and ensures you can keep track of where they’re coming from.

As a developer, it’s critical to think about how each code integration could affect each of your devices, and choose carefully which integrations to run on older devices. 

- Alon Dotan, Integration Engineer Team Lead at Unity

In the Google Play Console 

Finally, the Google Play console is a very useful place to find information about managing and reducing ANRs. 

6) Utilize information from the Google Play Console. Let’s say Google Play Console shows you that most ANRs are coming from a specific device. Even if you’re not sure how to solve the problem, you can always segment and filter out these devices. This should also apply to specific app versions or countries with high ANRs. 

This, of course, requires a balance - by segmenting out a certain device, for example, you’re also missing out on the benefits of third party code - so it’s always best to double check that you’re segmenting the right device before making any changes. 

Reducing ANRs is a marathon, not a sprint - but with the right tools, Unity LevelPlay developers have kept their in-app ANRs down, and you can do the same - ultimately giving users a smoother, easier, and more positive experience to make sure they keep coming back to enjoy your app. 

Let's put these tips to good use

Grow your app business with ironSource