YMC
YMC

Reputation: 5462

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

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.

Upvotes: 1

Views: 351

Answers (1)

Liyun Zhang - MSFT
Liyun Zhang - MSFT

Reputation: 14509

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.

Upvotes: 1

Related Questions