airbnb / paris

Define and apply styles to Android views programmatically
Apache License 2.0
1.91k stars 91 forks source link

android.content.res.Resources$NotFoundException: Font resource ID #0x104039d could not be retrieved #160

Open dideldum opened 3 years ago

dideldum commented 3 years ago

Hi,

I do a

Paris.style(this.bg).apply(style);

in my app (this.bg is a TextView and style is an int, which is set to an R.style.xyz value depending on certain conditions)

and receive an exception:

android.content.res.Resources$NotFoundException: Font resource ID #0x104039d could not be retrieved. at androidx.core.content.res.ResourcesCompat.loadFont(ResourcesCompat.java:407) at androidx.core.content.res.ResourcesCompat.getFont(ResourcesCompat.java:242) at com.airbnb.paris.utils.ContextExtensionsKt.getFont(ContextExtensions.kt:7) at com.airbnb.paris.typed_array_wrappers.TypedArrayTypedArrayWrapper.getFont(TypedArrayTypedArrayWrapper.kt:60) at android.widget.TextViewStyleApplier.processAttributes(TextViewStyleApplier.java:82) at com.airbnb.paris.StyleApplier.apply(StyleApplier.kt:63) at com.airbnb.paris.StyleApplier.apply(StyleApplier.kt:43) at de.dedio.apsmd.appbar.AppBarAdapter.recalculate(AppBarAdapter.java:86) at de.dedio.apsmd.appbar.AppBarAdapter.setGlucoseValue(AppBarAdapter.java:54) at de.dedio.apsmd.appbar.APSMDBaseActivity.onChanged(APSMDBaseActivity.java:97) at de.dedio.apsmd.appbar.APSMDBaseActivity.onChanged(APSMDBaseActivity.java:22) at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133) at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151) at androidx.lifecycle.LiveData.setValue(LiveData.java:309) at androidx.lifecycle.LiveData$1.run(LiveData.java:93) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:236) at android.app.ActivityThread.main(ActivityThread.java:8061) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)

Looks, like it has to do with the definition of "R.styleable.Paris_TextView_android_fontFamily" in the call

at android.widget.TextViewStyleApplier.processAttributes(TextViewStyleApplier.java:82)

which has an id 0x104039d, but no font is found for that id.

In my styles I haven't defined fonts, so Android Studio shows me the default used font family "sans serif medium" for the TextView.

How can I eliminate the exception?

I used implementation 'com.airbnb.android:paris:2.0.0' in the build.gradle to build my app.

nienienienie commented 2 years ago

same here

serhiiskyrda commented 6 months ago

Hi team Any updates on the issue above? Bothering our app as well, not massively, but periodically. Issue is exactly the same - Font resource ID could not be retrieved (we are not using dynamic fonts), only static ones. Thanks.

serhiiskyrda commented 6 months ago
Caused by android.content.res.Resources$NotFoundException: Font resource ID #0x1040402 could not be retrieved.
       at androidx.core.content.res.ResourcesCompat.loadFont(ResourcesCompat.java:573)
       at androidx.core.content.res.ResourcesCompat.getFont(ResourcesCompat.java:414)
       at com.airbnb.paris.utils.ContextExtensionsKt.getFont(ContextExtensions.kt:7)
       at com.airbnb.paris.typed_array_wrappers.TypedArrayTypedArrayWrapper.getFont(TypedArrayTypedArrayWrapper.kt:60)
       at android.widget.TextViewStyleApplier.processAttributes(TextViewStyleApplier.java:82)
       at com.airbnb.paris.StyleApplier.apply(StyleApplier.kt:63)
       at com.airbnb.paris.StyleApplier.apply(StyleApplier.kt:43)
       at com.airbnb.paris.extensions.TextViewStyleExtensionsKt.style(TextViewStyleExtensions.kt:42)