Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

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

Closed
vsfeedback opened this issue Jun 15, 2022 · 2 comments

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:It bothers me. A fix would be nice]
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

Version info:

203666-version.png


Original Comments

Feedback Bot on 5/23/2022, 08:00 PM:

(private comment, text removed)

Rajesh Uragonda on 5/25/2022, 08:35 AM:

(private comment, text removed)


Original Solutions

(no solutions)

@greg84
Copy link

greg84 commented Jun 18, 2022

Probably a duplicate of this: #15012

I'm working on putting together a repro. Appears to be for devices with low available storage the OS can clear the cache folder at any time. The Xamarin code doesn't handle this, as it caches a bunch of font file names and assumes they'll be available for the lifetime of the app.

@jfversluis
Copy link
Member

Duplicate of #15012

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants