无法检索字体资源 [英] Font resource could not be retrieved

查看:30
本文介绍了无法检索字体资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 compileSdktargetSdk 版本 27,在上一个版本中,我为我的项目使用了新的字体资源功能,但一天后我在这行出现了 3 次崩溃代码

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 typeface = ResourcesCompat.getFont(this, R.font.my_font);

并且崩溃报告说这是因为 android.content.res.Resources$NotFoundException 并且无法检索字体资源.所有 3 次崩溃都发生在使用 android 版本 5.1.1 的用户身上.这是支持库中的错误还是我做错了什么?

and the crash report says it's because of android.content.res.Resources$NotFoundException and Font resource could not be retrieved. All 3 crashes happened for users with android version 5.1.1. Is this a bug in support library or I'm doing something wrong?

推荐答案

我在使用 API 级别 16 上的可下载字体,使用 Google Play 服务 9.2.56(模拟器).

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

如果您正在使用它,则设备必须具有 Google Play 服务版本 11 或更高版本才能使用 Google 字体提供商(请参阅 docs).

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).

这篇关于无法检索字体资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆