My Xamarin application works perfectly on debug mode but crashes on release mod. I get this error: "Unfortunately App has stopped". I connected my phone through USB and when I run the app in release mode I get this error.
Unfortunately I can't debug the app in release mod because I get this message in the Output window: "Android application is running (debug is disabled in android project properties)", although the "Enable developer instrumentation" box is checked. I tried all linking alternative None/SDK/SDK and User but still doesn't work.
Is there a way to see what causes the crash, in a log file or something else ?
After struggling for hours, in my case it was because I was using a static resource from within App.xaml file while defining another resource above the declaration. The weird thing is that it worked perfectly in debug mode but for some reason, kept crashing in release mode. After pinpointing the issue, I reordered the declarations and the issue was resolved.
Regardless, what you can do is wrap the entire onCreate block in your MainActivity inside a try catch block and log the exception somewhere, e.g. a public http request logger or write it to a file. At the time of this writing, RequestBin had such free service. After creating an endpoint, just make a post request to the url with exception message as data. Here's an example :
protected override void OnCreate(Bundle bundle)
{
try
{
// oncreate logic
}
catch(Exception ex)
{
var client = new HttpClient();
client.PostAsync("your logger api url", new StringContent(ex.ToString())).Wait();
}
}
Hope this helps someone.
Can you try the following
Uninstall your local app that was deployed under Debug mode manually. Deploy Release app.
Update your version of Xamarin
Project setting → Android Options → Linker → Configuration = Release; Linking = Sdk Assemblies Only
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With