Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RuntimeException causes ANR instead of crash in android

I get ANR on both occasions:

throw new NullPointerException("random null pointer");

and

while(true){}

Only in exception part VM actually shuts down (D/AndroidRuntime﹕ Shutting down VM).

Second question is: How to force app to crash instead of ANR and get stack trace in logcat?

Update Changed Title From what is difference between ANR and Crash.

Update It occurred only about 3-4 months ago. Since then, only way to find what's crashing is to put try catch boxes everywhere with no reason at all.

like image 678
Alpha Avatar asked Mar 16 '23 13:03

Alpha


1 Answers

I am facing the same problem and when I am debugging I reach the code "throw RuntimeException" but I am also having an ANR instead.

The only clue that I have is that it started to happen when I configured Google Analytics in my app. Is this your case, @Alpha ?

I haven't gone beyond because I am kind of dealing with it like this, but some day I will debug specially for this issue with analytics.

EDIT: The issue is solved in Google Play Services 8.4. We can finally report uncaught exceptions! The app seems to be blocked for some seconds but finally exception is thrown and reported without ANR.

like image 75
Javier Delgado Avatar answered Mar 24 '23 06:03

Javier Delgado