Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between ANR and crash in Android?

Tags:

android

I have searched on the internet regarding what an ANR is. And I studied those references as well. But I don't get details regarding a crash in Android.

Can someone tell me the difference between ANR(Android not Responding) and a crash in Android?

like image 457
user3035740 Avatar asked Nov 26 '13 09:11

user3035740


People also ask

What is meant by ANR in Android?

Application Not Responding (ANR) errors are triggered when the UI thread of the application is not responding for more than 5 seconds. You can read more about ANRs and diagnosing ANRs in the Android documentation.

What is a crash Android?

An Android app crashes whenever there's an unexpected exit caused by an unhandled exception or signal. An app that is written using Java or Kotlin crashes if it throws an unhandled exception, represented by the Throwable class.

What is ANR in play console?

If your app stops responding, users get a dialog that allows them to wait or close the app. When these dialogs appear, they're known as "Application not responding" errors (or ANRs). ANR data is available in Play Console only.

What is ANR and how do you prevent it?

The worst thing that can happen to your app's responsiveness is an "Application Not Responding" (ANR) dialog. In Android, the system guards against applications that are insufficiently responsive for a period of time by displaying a dialog that says your app has stopped responding, such as the dialog in Figure 1.


1 Answers

ANR stands for Application Not Responding.

An ANR will occur if you are running a process on the UI thread which takes a long time, usually around 5 seconds. During this time the GUI (Graphical User Interface) will lock up which will result in anything the user presses will not be actioned. After the 5 seconds approx has occurred, if the thread still hasn't recovered then an ANR dialogue box is shown informing the user that the application is not responding and will give the user the choice to either wait, in the hope that the app will eventually recover, or to force close the app.

A crash is when an exception within the app has been thrown which has not been handled. For example, if you try to set the text of an EditText component, but the EditText is null and there is no try catch statement to catch the exception that your app will crash and will be force closed. The user will not see what caused the crash, they will be shown a dialogue telling that the app has force closed unexpectedly and will give them the option to send a bug report. In this example if you were to look in the bug report you would see the error caused by java.lang.NullPointerException.

like image 141
Boardy Avatar answered Sep 24 '22 17:09

Boardy