Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception: Failed to load font with url https://fonts.gstatic.com (google_fonts) #534

Closed
1 task done
aykutuludag opened this issue Jan 6, 2024 · 10 comments
Closed
1 task done
Labels
bug Something isn't working

Comments

@aykutuludag
Copy link

aykutuludag commented Jan 6, 2024

Package

google_fonts 6.1.0 (https://pub.dev/packages/google_fonts/versions/6.1.0)

Existing issue?

What happened?

I'm getting some error on Android via Firabase Crashlytics. Here is log output. I encountered this error once in my device. If this error occurs, Flutter loads default font in Android app and continue without crashing. But anyway I'm getting errors and maybe this will help to fix bugs. Error has different variants.

Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Exception: Failed to load font with url https://fonts.gstatic.com/s/a/e549403e4a007249673d041c55e7205d754210d79b962001d95a8313191aa3c2.ttf: HandshakeException: Handshake error in client (OS Error: 
	CERTIFICATE_VERIFY_FAILED: Hostname mismatch(handshake.cc:393))
       at ._httpFetchFontAndSaveToDevice(google_fonts_base.dart:263)
       at .loadFontIfNecessary(google_fonts_base.dart:180)
       at googleFontsTextStyle.<fn>(google_fonts_base.dart:117)
Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Exception: Failed to load font with url https://fonts.gstatic.com/s/a/e549403e4a007249673d041c55e7205d754210d79b962001d95a8313191aa3c2.ttf: ClientException with SocketException: Failed host lookup: 'fonts.gstatic.com' (OS Error: No address associated with hostname, errno = 7), uri=https://fonts.gstatic.com/s/a/e549403e4a007249673d041c55e7205d754210d79b962001d95a8313191aa3c2.ttf
       at ._httpFetchFontAndSaveToDevice(google_fonts_base.dart:263)
       at .loadFontIfNecessary(google_fonts_base.dart:180)
       at googleFontsTextStyle.<fn>(google_fonts_base.dart:117)
Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Exception: Failed to load font with url https://fonts.gstatic.com/s/a/e549403e4a007249673d041c55e7205d754210d79b962001d95a8313191aa3c2.ttf: ClientException with SocketException: Connection reset by peer (OS Error: Connection reset by peer, errno = 104), address = fonts.gstatic.com, port = 44498, uri=https://fonts.gstatic.com/s/a/e549403e4a007249673d041c55e7205d754210d79b962001d95a8313191aa3c2.ttf
       at ._httpFetchFontAndSaveToDevice(google_fonts_base.dart:263)
       at .loadFontIfNecessary(google_fonts_base.dart:180)
       at googleFontsTextStyle.<fn>(google_fonts_base.dart:117)

image_2024-01-06_171837299

Have a nice day

Relevant log output

[√] Flutter (Channel stable, 3.16.0, on Microsoft Windows [Version 10.0.22621.2861], locale en-US)
    • Flutter version 3.16.0 on channel stable at C:\FlutterSDK
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision db7ef5bf9f (7 weeks ago), 2023-11-15 11:25:44 -0800
    • Engine revision 74d16627b9
    • Dart version 3.2.0
    • DevTools version 2.28.2

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\AndroidSDK
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = C:\AndroidSDK
    • ANDROID_SDK_ROOT = C:\AndroidSDK
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.25)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
    • Visual Studio Build Tools 2019 version 16.11.33423.256
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2022.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = C:\Program Files\Android\Android Studio
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)

[√] VS Code (version 1.79.2)
    • VS Code at C:\Users\Aykut\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.22621.2861]
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 117.0.5938.134
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 120.0.2210.91

[√] Network resources
    • All expected network resources are available.

• No issues found!
@aykutuludag aykutuludag added bug Something isn't working triage Issues that haven't been triaged labels Jan 6, 2024
@aykutuludag
Copy link
Author

aykutuludag commented Feb 15, 2024

image

I'm still getting a lot of error. Is there any update to fix this issue? I found similar issues https://stackoverflow.com/questions/61124989/error-google-fonts-was-unable-to-load-font but without conclusive answer.

UPDATE
As far as I can see problem is about internet connection BETWEEN DEVICE TO GSTATIC.COM. I was thinking google_fonts library imported fonts into app when I build apk/ipa. However, I think the fonts are downloaded when the application is first started on the device.

SUGGESTION
So my simple suggestions is: Is it possible to change library to insert fonts on buildtime, not first runtime on device. Kind regards.

@aykutuludag
Copy link
Author

Same issue: #537

@aykutuludag
Copy link
Author

aykutuludag commented Feb 15, 2024

#521 is same issue.

@aykutuludag
Copy link
Author

aykutuludag commented Feb 15, 2024

#507 is same issue.

@aykutuludag aykutuludag changed the title Exception: Failed to load font with url https://fonts.gstatic.com Exception: Failed to load font with url https://fonts.gstatic.com (google_fonts) Feb 15, 2024
@aykutuludag
Copy link
Author

@rodydavis

@LuuNgocLan
Copy link

LuuNgocLan commented Feb 16, 2024

I got the same issue on Android device reported by Firebase crashlytics

  • Sdk_gphone64_arm64: 75%
  • Galaxy S20 5G: 25%

image

When I turn off wifi and open the app, it can't load Google font from network

@vargab95
Copy link

I think, the solution is already documented here.

The google_fonts package will automatically use matching font files in your pubspec.yaml's assets (rather than fetching them at runtime via HTTP). Once you've settled on the fonts you want to use:

@guidezpl
Copy link
Collaborator

This is not a solution, just another option for fetching fonts. I'm going to create a pinned issue for this

@guidezpl
Copy link
Collaborator

Closing in favor of #560

@guidezpl guidezpl closed this as not planned Won't fix, can't repro, duplicate, stale Feb 26, 2024
@guidezpl guidezpl removed the triage Issues that haven't been triaged label Feb 26, 2024
@medrami-dev
Copy link

same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants