Bug 8900 - Uncaught exception in OnCreate doesn't terminate app
Summary: Uncaught exception in OnCreate doesn't terminate app
Status: RESOLVED DUPLICATE of bug 7634
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.4.x
Hardware: PC Windows
: High normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2012-12-12 08:50 UTC by Sebastian Krysmanski
Modified: 2014-01-14 15:32 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 7634

Description Sebastian Krysmanski 2012-12-12 08:50:55 UTC
An uncaught exception in "OnCreate()" of the main activity doesn't terminate the app anymore. Instead MfA (or Android?) tries to restart the app over and over again.

Code to trigger the behavior:

http://pastebin.com/QWeKM5Yg

Android Log (I added dashed lines to mark the portions that are repeating):

http://pastebin.com/ywEfEQS7
Comment 1 Jonathan Pryor 2012-12-12 10:26:47 UTC
This is default Android behavior, not a Mono for Android "bug":

http://stackoverflow.com/questions/11502953/android-kill-process-restarting-application

Reading between the lines:

http://developer.android.com/guide/components/processes-and-threads.html#Processes
> A process is started again for those components when there's again work for them to do.

You have a visible activity. It's thus the topmost Activity, and what the user is interacting with. It crashes/dies. As far as Android is concerned, the user is _still_ interacting with the Activity, and thus Android will restart the process+Activity so that the user can interact with it.

At least this is the behavior I've observed.

The "fix" is to keep the Activity from being topmost: hit the Home button so that the Activity is no longer foremost. This will keep the process from continually (restarting+crashing)*.
Comment 2 Sebastian Krysmanski 2012-12-12 11:23:48 UTC
I just created a Java Android app and it terminates when there is an uncaught exception in "onCreate()" - no restarting at all.
Comment 3 Sebastian Krysmanski 2013-02-04 12:09:35 UTC
I'm sorry but I have to reopen this bug. This behavior definitely differs from the Android-Java behavior. 

Also, because MfA tries to start the app over and over again, the Android log gets flooded with the same error message. In some cases, there are so many messages that they will freeze Visual Studio during deployment. (The "Android Device Logging" window will eat up all CPU by trying to keep up with the message flood.)
Comment 4 Jonathan Pryor 2014-01-14 15:32:53 UTC

*** This bug has been marked as a duplicate of bug 7634 ***