Yuri Muhin's CV
When the UI thread of an Android app is blocked for too long, an "Application Not Responding" (ANR) error is triggered. If the app is in the foreground, the system displays a dialog to the user, as shown in figure 1. The ANR dialog gives the user the opportunity to force quit the app.
1) First option. If we have something of that on our emulator, as well as on our android physical device - in developer options we select "bug report" option. When we select "bug report" option on our emulator, it start generating collecting bug report from our device. This bug report has not only information about our recently used apps, it also has information about our device state as of the moment: what is our battery level, what is our network connection level,what was the memory in our device at this moment, etc. So, it has a lot of information about our device and everything what is happening within our system. Once we hit 'report', it will generate our bug report. It's gonna take some time, and we will see notification that it is ready and after that we will be able to retrieve it from our phone or to send to the developers using sharing options.
2) Second option. Another way. We need to go inside our phone. If something like that is happening on our device, there are will be special folder generated - 'anr' folder under 'data' directory. And we will be able to find traces and retrieve them from our device and attach to the bug report.
Steps (using command prompt):
a) adb root - we use device as root users;
b) adb shell - we go inside our device;
c) after symbol "#" type ls to enter phone directory;
d) after symbol "#" type cd data to enter 'data' folder;
e) after symbol "#" type ls to enter 'data' folder directory;
Observe : 'anr' folder is generated inside 'data' folder. It is only there, if something like 'UI don't responding' happen on your phone (virtual device). If it never happen, this directory will not be created. So, this event creates this 'anr' directory under 'data' directory.
f) after symbol "#" type cd anr to enter anr folder;
g) after symbol "#" type ls to enter anr folder directory;
Then all we need to do - is to pull these files from our phone and attach them to our bug report.
But first of all, we need to exit our phone (or virtual device) and to go to our home working directory, to our computer.
We need to get back to our physical machine (host machine) and then we can pull these files.
h) after symbol "#" we type 'exit' to move to our home working directory;
i) we try to pull whole folder typing following: adb pull /data/anr;
g) we type dir (windows) in order to enter current directory and to check if the 'anr' folder is there;
Observe: The anr folder is attached.
k) type cd anr to enter anr folder;
l) type dir (windows) to see folder directory.
Now we see files, which we do need to attach to bug report in case that we have something like: "Dice Roller isn't responding".
Interview question:
What is anr error and how does it differ from crashes?
Answer: It is not a crash, the app is not crashing, it got's frozen, it not responding, because something is happening on the main or UI thread. Something is blocking my application from work and it is stuck over here and no longer responding on user actions or anything.
So, it is just got frozen. In this case adb logcat would not be an option for me.
I can use bug report option on my device or on my emulator; or even better if I can turn myself into root user, I can just go ahead and get inside my device and pull the files, related to this particular anr event. And then it's gonna be my developer, who is going to use android profiler - something that it is available with android studio and he will be able to try to debug this issue, try to find what is happening, what is blocking this thread and what is the reason, and fix this error.