flutter - 用于颤振的 Google 字体包无法在发布模式下加载字体
问题描述
我在我的颤振应用程序
https://pub.dev/packages/google_fonts中使用了 Google 字体包
该应用程序在调试模式下运行良好,字体加载没有任何问题。
但是,当我在发布模式下构建和运行应用程序时,字体无法加载。大多数情况下,应用程序会崩溃,有时会加载默认的 Roboto 字体。
GitHub 上存在一些问题,但其中任何一个都不能解决我的问题。我尝试清理构建文件夹,重新检查pubspec.yaml
文件,检查google_fonts
包版本,验证互联网连接,甚至重新创建项目。但没有什么能解决问题。
版本:
google_fonts: ^1.1.0
flutter run --release
我在使用命令运行应用程序时收到此错误日志
这是我收到的错误:
I/flutter (17872): Error: google_fonts was unable to load font Montserrat-SemiBold because the following exception occured:
I/flutter (17872): Exception: Failed to load font with url: https://fonts.gstatic.com/s/a/5f82f6e55db43e905c6ab9d04395566b243c41798d6a53545ffbd10ed6c424c4.ttf
I/flutter (17872): Error: google_fonts was unable to load font Montserrat-Medium because the following exception occured:
I/flutter (17872): Exception: Failed to load font with url: https://fonts.gstatic.com/s/a/cec0f6e0bfbfaa352eb189f0eb220916dd278b02aaf824be87055ba5cc38d58b.ttf
I/flutter (17872): Error: google_fonts was unable to load font Montserrat-Regular because the following exception occured:
I/flutter (17872): Exception: Failed to load font with url: https://fonts.gstatic.com/s/a/470e93c06a9fffa6851375f54047917a9d774ed6027d9f044cd1bc8d4cd5630b.ttf
解决方案
这个错误可能有很多原因,但我认为这两个之一是这种情况:
- 如果它只发生在 android 上,那么也许你没有将它添加
<uses-permission android:name="android.permission.INTERNET" />
到你的清单文件中。 - 您所在的国家/地区禁止此服务
推荐阅读
- html - 防止文本中断到一半
- spring-boot - 启用弹簧启动执行器时的 Solr 自动配置问题
- python - Python 在启动时运行
- amazon-web-services - AWS Serverless:将用户权限存储在不同资源上的最佳方式
- powershell - -notmatch 和 win32_process 遇到问题
- python - 如何使用自定义方法腌制转储 tfidf 矢量化器?
- weka - 我们可以使用 WEKA 工具对屏蔽数据进行分析吗?
- css - 是否可以禁用按住按钮时运行的 React-Bootstrap 按钮颜色更改动画?
- python - 如何将列合并到熊猫数据透视表中的索引?
- javascript - JavaScript 中的倒数计时器,只打印素数