Runtimeexception Causes Anr Instead Of Crash In Android
Solution 1:
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.
Solution 2:
Crash : the application has stopped because it threw an unchecked exception, so the JVM stops.
ANR : your application stopped responding, meaning the UI thread is blocked by an expensive or long operation. For example, doing while(true){}
on the UI thread.
I don't think you have a way to catch the system's built-in mechanism that triggers ANR dialogs so you could throw a RuntimeException and have your app crash. I'm not sure why you would want to do that either, it would be much better to try and follow guidelines here so you can avoid ANR and crashes altogether.
Solution 3:
App Crash/Force Close
http://www.quora.com/What-causes-Android-apps-to-force-close
If the app uses up too much memory or processing power, the app will be forced to close (crash). The best way to make sure that doesn't happen is to write very efficient code that doesn't use a lot of memory, and to constantly test your application on a variety of devices (primarily the older devices because they have less RAM and processing power).And exceptions too behind the reason.
ANR
http://developer.android.com/training/articles/perf-anr.html
Solution 4:
I had this problem when changing the default exception handler. In my case I had a NullPointerException when catching the exception, which caused a loop, which caused the ANR.
Like @Fighter42 mentioned in a comment, it can occur in any library which overrides the default exception behavior.
Hope this helps!
Solution 5:
I am using now Google Play Services 8.4 and uncaught exception do not cause ANR anymore. I have been using it for a while and it may be OK in earlier versions too.
The result now is that when there is an uncaught exception, the UI does not respond for some seconds, but finally the exception is thrown and reported in Google Analytics.
Post a Comment for "Runtimeexception Causes Anr Instead Of Crash In Android"