Home > Net >  Due to missing style Android app crashes in the Release mode, but not in Debug mode
Due to missing style Android app crashes in the Release mode, but not in Debug mode

Time:01-04

I had a problem in my xaml code referencing style that did not exist:

<Label Text="Reset" Style="{StaticResource Key=NonExistentStyle}" />

When I compile and run the code under "DEBUG" configuration in VS 2022 it does not give me any error/warning during compile or run-time, executing on Android device and Android emulator. However when I switch to "RELEASE" configuration and publish the app, install the apk on my Android device and run it the app crashes, as I figured out later due to the missing style, but took me some time to figure it out.

  • Is there a way to ask the debug mode be more strict in things like missing style references, and fail on all the same things RELEASE configuration to fail on?
  • and how do you troubleshoot problems in xaml overall? It's not the place I can put try {} catch {}, so there must be other ways to grab more log information about Android app crashes.

CodePudding user response:

I have created a Xamarin.Forms project and a Maui project to test missing style.

In the Xamarin.Forms project, it will throw the Xamarin.Forms.Xaml.XamlParseException and tell you the static resource not found when you debug the project on the android device.

But in the Maui project, this exception will be ignored in the debug mode. And then I found a similar issue about this problem on the github, you can follow up it.

Or you can report a new issue to the github and follow up it.

  • Related