Skip to content Skip to sidebar Skip to footer

Font Resource Could Not Be Retrieved

I'm using compileSdk and targetSdk version 27 and in last release I used new font resource feature for my project but after a day I got 3 crashes for this line of code Typeface typ

Solution 1:

I got the same crash while using Downloadable fonts on API level 16 with Google Play services 9.2.56 (emulator).

If you're using this, then a device must have Google Play services version 11 or higher to use the Google Fonts provider (see this note in the docs).

Solution 2:

Had this same issue, noticed a detail in the docs that helped:

When you declare font families in XML layout through the support library, use the app namespace to ensure your fonts load.

<?xml version="1.0" encoding="utf-8"?><font-familyxmlns:app="http://schemas.android.com/apk/res-auto"><fontapp:fontStyle="normal"app:fontWeight="400"app:font="@font/myfont-Regular"/><fontapp:fontStyle="italic"app:fontWeight="400"app:font="@font/myfont-Italic" /></font-family>

I had been using the 'android' namespace before, changing to the 'app' namespace made my fonts load on older devices correctly.

Solution 3:

I had the same problem with a TTF file in R.font when using ResourcesCompat.getFont().

It turns out that Android didn't like this TTF file for some reason. There was no info in logcat, but debugging showed that TypefaceCompat.createFromResourcesFontFile() failed.

I replaced the TTF file with another, similar font and had no problems since.

Solution 4:

In my case, even after upgrading Gradle version to most recent one didn't work. What worked for me was a really trivial solution, updating the dependencies version to latest versions. I don't know it might work or not in your case, but maybe you should try doing it once.

Solution 5:

while using Downloadable fonts on API level 16

The fonts need to be downloaded so its better to check the Internet connection and download them, even when they are provided from the fonts folder.

Post a Comment for "Font Resource Could Not Be Retrieved"