question

80240195 avatar image
0 Votes"
80240195 asked JarvanZhang-MSFT commented

How to solve this error?

my code error is

Java.Lang.RuntimeException
Message=Font asset not found FontAwesome5Regular.otf

the error be in code LoadApplication(new App());

protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);

         Xamarin.Essentials.Platform.Init(this, savedInstanceState);
         global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
         LoadApplication(new App()); 
     }



dotnet-xamarin
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Java.Lang.RuntimeException Message=Font asset not found FontAwesome5Regular.otf

Hi, 80240195. How did you use the custom font in Xamarin.Forms? Could you post the related code? To use the custom font in Xamarin.Forms, you could place the font file in the shared project and set the BuildAction as EmbeddedResource. Then head over to the AssemblyInfo.cs and add this new fancy export code.

[assembly: ExportFont("Lobster-Regular.ttf", Alias = "Lobster")]

Tutorial: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/text/fonts

If you want to customize font for each platform, please place the font files to each platform project. For Android, place the file in your Assets folder and ensure the build type is AndroidAsset.

0 Votes 0 ·

1 Answer

HemalathaMarikumar-1823 avatar image
0 Votes"
HemalathaMarikumar-1823 answered HemalathaMarikumar-1823 edited

Hi @80240195,

Can you make sure whether you have added otf file to the Assets folder of the android project in Xamarin.Forms ?. If then, please ensure whether it has Build Action as Android Assets

79023-project.png



project.png (53.4 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.