We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

(Android) Java.Lang.RuntimeException: Font asset not found

Hi,

When I use this code :
<sfpicker:SfPicker
  HeaderBackgroundColor="#3F89C4"
  HeaderFontFamily="{StaticResource Font-BebasNeue-Regular}"
  HeaderFontSize="22"
  HeaderText="SELECT ITEM"
.../
My application crash with this exception :
UNHANDLED EXCEPTION:
Java.Lang.RuntimeException: Font asset not found BebasNeue-Regular.otf#BebasNeue
  at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <42bcf67b56bc4c909c2a5edee682522b>:0 
  at Java.Interop.JniPeerMembers+JniStaticMethods.InvokeObjectMethod (System.String encodedMember, Java.Interop.JniArgumentValue* parameters) [0x00018] in <42bcf67b56bc4c909c2a5edee682522b>:0 
  at Android.Graphics.Typeface.CreateFromAsset (Android.Content.Res.AssetManager mgr, System.String path) [0x0004b] in <8c07a09624c14764b43f6b946a5a1f23>:0 
  at Syncfusion.SfPicker.XForms.Droid.SfPickerMapping.GetNativeFont (Xamarin.Forms.FontAttributes font, System.String fontFamily) [0x00049] in <0459997e36954c0692de1487d5fc3970>:0 
  at Syncfusion.SfPicker.XForms.Droid.SfPickerMapping.OnPickerPropertiesChanged (System.String propertyName, Syncfusion.SfPicker.XForms.SfPicker formsPicker, Com.Syncfusion.SfPicker.SfPicker nativePicker) [0x00d0a] in <0459997e36954c0692de1487d5fc3970>:0 
  at Syncfusion.SfPicker.XForms.Droid.SfPickerRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs`1[TElement] e) [0x00090] in <0459997e36954c0692de1487d5fc3970>:0 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000b8] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:230 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:127 
  at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:344 
  at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000af] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:138 
  at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00139] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:334 
  at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:110 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:439 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000d5] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:233 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:127 
  at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:344 
  at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000af] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:138 
  at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00139] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:334 
  at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:110 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:439 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000d5] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:233 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:127 
  at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Support.V4.App.FragmentManager fragmentManager, Android.Content.Context context) [0x00031] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:391 
  at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnCreateView (Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState) [0x00008] in D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\FragmentContainer.cs:56 
  at Android.Support.V4.App.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) [0x00020] in :0 
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.46(intptr,intptr,intptr,intptr,intptr)

But if I use this code :
<sfpicker:SfPicker
...>
  <sfpicker:SfPicker.HeaderView>
    <Label
      FontFamily="{StaticResource Font-BebasNeue-Regular}"
      FontSize="22"
      Text="SELECT ITEM"/>
  </sfpicker:SfPicker.HeaderView>
</sfpicker:SfPicker>
It doesn't crash.

The same problem happens with FontFamily on SelectedItem and UnSelectedItem.

Also, why SelectedItem is automatically the first one ? I have to set to null after initializing ItemSource.

Benoît.

PS : Where is the code tag ? It looks awful.

1 Reply

HM Hemalatha Marikumar Syncfusion Team November 18, 2019 11:36 AM UTC

Hi Nelissen, 
  
Greetings from Syncfusion. 

Query1: App to Crash with exception
 
  
We have validated your query and there is currently no support in SfPicker to submit font with the name of the font family. Alternatively, the font with the name of the font file can be applied as in the code snippet below. 
  
CodeSnippet[XAML]: 
  
  <ResourceDictionary> 
  
            <OnPlatform x:TypeArguments="x:String" x:Key="NestedTabFontFamily"> 
                <On Platform="UWP" Value="NestedTab.ttf#NestedTab" /> 
                <On Platform="Android" Value="NestedTab.ttf" /> 
                <On Platform="iOS" Value="NestedTab" /> 
            </OnPlatform> 
            
</ResourceDictionary> 
  
<picker:SfPicker HeaderBackgroundColor="#3F89C4"   HeaderFontSize="22" HeaderFontFamily="{StaticResource  NestedTabFontFamily}" HeaderText="H" PickerMode="Dialog"> 

We have already logged this as feature request. You can track the current status of the application for this feature here. We will include this feature in any of our upcoming release.
 
  
Check the following sample to use the Custom FontIcon based on the provided code snippet in the SfPicker as reference. 

Query2: Null value to Picker
 
  
Currently we don't have support for “To set null value to Picker”. We would like to let you know that we have already logged a feature request on this, and it can be tracked through our feedback portal below.  
 
 
Please upvote this feature to make this our priority. While this feature itself is important we will prioritize the features every release, based on the user demands. 
 
If you have any more specification/suggestions to the feature request, you can add it as a comment in the portal. 

Please let us know if you have any further assistance on this
 
Regards,   
Hemalatha M. 


Loader.
Up arrow icon