dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.19k stars 1.75k forks source link

[Android] AddEmbeddedResourceFont Shows Exception Warning in Output Window #24059

Open BrundhaVelusamy opened 2 months ago

BrundhaVelusamy commented 2 months ago

Description

Description:

When registering a custom font as an embedded resource in a MAUI project, the following error appears in the output window when deploying on Android:

java.lang.RuntimeException: Font asset not found /data/user/0/com.companyname.mauisampleapplication/cache/Maui Material Assets.ttf

Reference sample: MauiSampleApplication.zip

Steps to Reproduce

  1. Create the simple Maui application.
  2. Include the custom font file in the resource.
  3. Register the font file as embedded resource.
  4. Run the sample on Android.
  5. The mentioned warning will shown on the output window.

Link to public reproduction project repository

No response

Version with bug

8.0.71 SR7.1

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

github-actions[bot] commented 2 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

RoiChen001 commented 2 months ago

I can repro this issue at Android platform on the latest 17.11.0 Preview 6.0 (8.0.71 & 8.0.70).

spreedated commented 2 months ago

Also here to confirm the issue on the latest MAUI, compiled against net8.0-android34.0.

superwilly1 commented 1 month ago

When debugging the provided MauiSampleApplication solution on Android, I also see output messages about the fonts (not just Maui Material Assets.ttf but also OpenSans-Regular.ttf).

Messages in the output window: Java.Lang.RuntimeException: Font asset not found /data/user/0/com.companyname.mauisampleapplication/cache/Maui Material Assets.ttf And: Java.Lang.RuntimeException: Font asset not found OpenSans-Regular.ttf

But the app just runs and shows the correct fonts. Also the release version seems to work without crashing.

My issue is, that we are using a 3rd party control (via a nuget package) that uses an embedded font. Debug works, but the release version crashes (on some Android devices, not all) with the same messages as above, only then as fatal exceptions: Abort message: '[ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.RuntimeException: Font asset not found /data/user/0/<ApplicationId>/cache/Maui Material Assets.ttf and: Abort message: '[ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.RuntimeException: Font asset not found OpenSansRegular

So our issue is: using a nuget package that contains an embedded font crashes the release version of the app on some Android devices. The app starts up correct, but then whenever the fonts are being used, the app crashes.

BrundhaVelusamy commented 1 week ago

Please provide a high priority for the resolution of this issue.

Relevant issue: https://github.com/dotnet/maui/issues/19804