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
21.95k stars 1.7k forks source link

[Android, .NET MAUI 9.0 Preview 5] When building with Visual Studio 17.11.0 Preview 2.1, Maui fails randomly to import the fonts, but still finishes building without errors. #23364

Open janne-hmp opened 1 month ago

janne-hmp commented 1 month ago

Description

Randomly, when building a Maui app with Visual Studio in Windows, the Android version of Maui fails randomly to import the fonts, but still builds apparently fine. Other versions (iOS, Windows) seem to always build fine. This can be especially problematic with release builds going to Google Play Store if the fonts are left out of the package without any errors or warnings.

Steps to Reproduce

Not sure, since it happens very randomly, but still consistently every now and then.

Link to public reproduction project repository

https://github.com/hyvanmielenpelit/GnollHack

Version with bug

9.0.0-preview.4.10690

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

Android 14

Did you find any workaround?

Delete obj and bin directories and hope that the fonts are included next time when building.

Relevant log output

No response

github-actions[bot] commented 1 month 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.

jfversluis commented 1 month ago

Possibly related/duplicate #23268

janne-hmp commented 1 month ago

I'm pretty sure this is related to the very unreliably working resizetizer on Android. Fonts are copied (for whatever reason) to obj/Debug/net9.0/resizetizer/f directory and this seems to fail frequently along with many other resizetizer tasks on Android.

The workaround is not to use resizetizer with fonts on Android, but rather copy them to the right location using MauiAsset, as follows:

        <MauiFont Include="Resources\Fonts\*" Condition="'$(TargetFramework)'!='net9.0-android'" />
        <MauiAsset Include="Resources\Fonts\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" Condition="'$(TargetFramework)'=='net9.0-android'" />
jonmdev commented 2 weeks ago

This is happening in .NET 8.0 now also. It only happens on Debug mode, not Release for me.

Something has changed. This only started in the last few weeks for me.

Deleting bin and obj sometimes works. I have only had it happen ~5 times so I can't pin down what I'm doing if anything to trigger or fix it.

But I am not in .NET 9.0 so it is certainly not a .NET 9.0 only issue.

I am using

<ItemGroup>
    <PackageReference Include="Microsoft.Maui.Controls" Version="8.0.61" />
    <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.61" />
</ItemGroup>