CSharpShellApp
CSharpShellApp copied to clipboard
Installed APK crash after start
2 APKs I made work well on some devices. But on one they crash emediatly afte start without any hint why. Is there a way to report/log the cause of a crash, for example to compile a debug version? A try-catch in the main() did not work.
Yes, it is relatively easy to setup. For Xamarin.Forms do it in the App.cs file, before InitializeComponent. Try just a popup dialog for the 'Log' method.
AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;
AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironmentOnUnhandledException;
private void AndroidEnvironmentOnUnhandledException(object sender, RaiseThrowableEventArgs e)
{
e.Handled = true;
Log(e.Exception);
}
private void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
e.SetObserved();
Log(e.Exception);
}
private void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Log(e.ExceptionObject as Exception);
}
Or use an app called Logcat Reader and filter by package name. But this app requires granting a permission via ADB from a PC.
Tanks muck, I will try it out.
(No PC and electricity, I work on a solar pannel and a phone only :-)
Tanks much! I needed a day to find the bug, it was RunOnUiThread related
I get it don do shoot down a code with a stack overflow with a infnite recursion. This was not catched with any of the exeption handlers. (because I worked on differend code parts, it taken a while before I found he error) Is thete a way to catch a stack overflow, at least in the IDE to write a log before its hart crash? I ask too because of curiosity, there are exceptions which can not be handeled? Not even from the IDE?
https://learn.microsoft.com/en-us/dotnet/api/system.stackoverflowexception?redirectedfrom=MSDN&view=net-6.0
No, StackOverflow is the one exception that silently crashes the entire shared runtime since there is no way to internally catch it. I've implemented a very, very basic "stack overflow" analyzer/catcher in the IDE's debug mode, so that might work for some cases.