question

UragondaRajesh-4347 avatar image
1 Vote"
UragondaRajesh-4347 asked UragondaRajesh-4347 commented

Xamarin form app : Java.Lang.RuntimeException: Font asset not found /data/user/0/com.packagenamemodified/cache/Barlow-SemiBold.ttf

Recently we have noticed "Font not found exception" happening randomly.
This issue is happening on android devices and seems to be not specific to device or android version and dont have any specific scenario, it happens randomly.

Below are the stack traces found.

GroupableItemsViewAdapter_2.onBindViewHolder
GroupableItemsViewAdapter_2.java, line 47
Java.Lang.RuntimeException: Font asset not found /data/user/0/com.packagenamemodified/cache/Barlow-SemiBold.ttf

Stacktrace:

 JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args)
 JniPeerMembers+JniStaticMethods.InvokeObjectMethod (System.String encodedMember, Java.Interop.JniArgumentValue* parameters)
 Typeface.CreateFromFile (System.String path)
 FontExtensions.TryGetFromAssets (System.String fontName)
 FontExtensions.ToTypeFace (System.String fontfamily, Xamarin.Forms.FontAttributes attr)
 FontExtensions.CreateTypeface (System.Tuple`2[T1,T2] key)
 ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory)
 FontExtensions.ToTypeface (System.String fontFamily, Xamarin.Forms.FontAttributes fontAttributes)
 FontExtensions.ToTypeface (Xamarin.Forms.Font self)
 LabelRenderer.UpdateFont ()
 LabelRenderer.UpdateText ()
 LabelRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs`1[TElement] e)
 LabelRenderer.set_Element (Xamarin.Forms.Label value)
 IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element)
 Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context)
 VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren)
 VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement)
 VisualElementPackager.Load ()
 VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager)
 VisualElementRenderer`1[TElement].SetElement (TElement element)
 IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element)
 Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context)
 VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren)
 VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement)
 VisualElementPackager.Load ()
 VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager)
 VisualElementRenderer`1[TElement].SetElement (TElement element)
 IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element)
 Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context)
 VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren)
 VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement)
 VisualElementPackager.Load ()
 VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager)
 VisualElementRenderer`1[TElement].SetElement (TElement element)
 IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element)
 Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context)
 VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren)
 VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement)
 VisualElementPackager.Load ()
 FrameRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs`1[TElement] e)
 FrameRenderer.set_Element (Xamarin.Forms.Frame value)
 IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element)
 Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context)
 VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren)
 VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement)
 VisualElementPackager.Load ()
 VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager)
 VisualElementRenderer`1[TElement].SetElement (TElement element)
 IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element)
 Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context)
 ItemContentView.CreateRenderer (Xamarin.Forms.View view, Android.Content.Context context)
 ItemContentView.RealizeContent (Xamarin.Forms.View view)
 TemplatedItemViewHolder.Bind (System.Object itemBindingContext, Xamarin.Forms.ItemsView itemsView, System.Action`1[T] reportMeasure, System.Nullable`1[T] size)
 ItemsViewAdapter`2[TItemsView,TItemsViewSource].BindTemplatedItemViewHolder (Xamarin.Forms.Platform.Android.TemplatedItemViewHolder templatedItemViewHolder, System.Object context)
 StructuredItemsViewAdapter`2[TItemsView,TItemsViewSource].BindTemplatedItemViewHolder (Xamarin.Forms.Platform.Android.TemplatedItemViewHolder templatedItemViewHolder, System.Object context)
 StructuredItemsViewAdapter`2[TItemsView,TItemsViewSource].OnBindViewHolder (AndroidX.RecyclerView.Widget.RecyclerView+ViewHolder holder, System.Int32 position)
 SelectableItemsViewAdapter`2[TItemsView,TItemsSource].OnBindViewHolder (AndroidX.RecyclerView.Widget.RecyclerView+ViewHolder holder, System.Int32 position)
 GroupableItemsViewAdapter`2[TItemsView,TItemsViewSource].OnBindViewHolder (AndroidX.RecyclerView.Widget.RecyclerView+ViewHolder holder, System.Int32 position)
 RecyclerView+Adapter.n_OnBindViewHolder_Landroidx_recyclerview_widget_RecyclerView_ViewHolder_I (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_holder, System.Int32 position)
 (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.118(intptr,intptr,intptr,int)
 java.lang.RuntimeException: Font asset not found /data/user/0/com.packagenamemodified/cache/Barlow-SemiBold.ttf
 android.graphics.Typeface.createFromFile Typeface.java:1188
 android.graphics.Typeface.createFromFile Typeface.java:1202
 crc643f46942d9dd1fff9.GroupableItemsViewAdapter_2.n_onBindViewHolder(Native Method)



crc643f46942d9dd1fff9.ShellContentFragment.onCreateView
ShellContentFragment.java, line 69
Java.Lang.RuntimeException: Font not found /data/user/0/com.packagenamemodified/cache/Lora-Bold.ttf

 JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args)
 JniPeerMembers+JniStaticMethods.InvokeObjectMethod (System.String encodedMember, Java.Interop.JniArgumentValue* parameters)
 Typeface.CreateFromFile (System.String path)
 FontExtensions.TryGetFromAssets (System.String fontName)
 FontExtensions.ToTypeFace (System.String fontfamily, Xamarin.Forms.FontAttributes attr)
 FontExtensions.CreateTypeface (System.Tuple`2[T1,T2] key)
 ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory)
 FontExtensions.ToTypeface (System.String fontFamily, Xamarin.Forms.FontAttributes fontAttributes)
 FontExtensions.ToTypeface (Xamarin.Forms.Font self)
 LabelRenderer.UpdateFont ()
 LabelRenderer.UpdateText ()
 LabelRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs`1[TElement] e)
 LabelRenderer.set_Element (Xamarin.Forms.Label value)
 IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element)
 Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context)
 VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren)
 VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement)
 VisualElementPackager.Load ()
 VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager)
 VisualElementRenderer`1[TElement].SetElement (TElement element)
 IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element)
 Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context)
 ScrollViewContainer.set_ChildView (Xamarin.Forms.View value)
 ScrollViewRenderer.LoadContent ()
 ScrollViewRenderer.SetElement (Xamarin.Forms.VisualElement element)
 Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context)
 VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren)
 VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement)
 VisualElementPackager.Load ()
 VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager)
 VisualElementRenderer`1[TElement].SetElement (TElement element)
 IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element)
 Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context)
 ShellContentFragment.OnCreateView (Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState)
 Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_inflater, System.IntPtr native_container, System.IntPtr native_savedInstanceState)
 (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.115(intptr,intptr,intptr,intptr,intptr)
 java.lang.RuntimeException: Font not found /data/user/0/com.packagenamemodified/cache/Lora-Bold.ttf
 android.graphics.Typeface.createFromFile Typeface.java:930
dotnet-xamarin
· 4
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.

Have you tried to clean up the bin/ and obj/ folder and rebuild the project?

Did you update your VS in recent time?

I found an issue might be helpful for you. Random Android Font resource issues after upgrading to VS 16.6.2.

0 Votes 0 ·

Thanks for sharing the github issue.

It says the issue is fixed on Xamarin.Android SDK version 11.0.0.3.

I am already on the updated version and this should not be happening.
Unable to figure what is the cause, any inputs on this would be helpful.

Thanks,
Rajesh Uragonda.
203666-version.png


0 Votes 0 ·
version.png (49.7 KiB)
YonglunLiu-MSFT avatar image YonglunLiu-MSFT UragondaRajesh-4347 ·

I used Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.1.6 and Xamarin.Android SDK 12.2.4.3 (d17-1/fc1125e) testing for hours, and the error is never occurring.

Does the issue occur in a new project?

If so, you can refer to Report a problem with the Visual Studio product or installer to report this problem.

0 Votes 0 ·
Show more comments

0 Answers