Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Flutter build stops: a font file in pubspec.yaml cannot be found

ErrorError: unable to locate asset entry in pubspec.yaml: "assets/fonts/Lato-Regular.ttf".

Short answer

This error is raised for an entry under the fonts: section of pubspec.yaml. Flutter resolved the asset path, found no file there, and failed the build. The path is read relative to pubspec.yaml, so check that the file exists at that exact path, and that the fonts: block is nested correctly under flutter:.

  • Applies to Flutter 3.3x stable
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Run the build from the project root and list the font file the message names. If the file is not listed, the cause is the path.

    ls -l assets/fonts/Lato-Regular.ttf
    grep -n -A6 'fonts:' pubspec.yaml
  2. 2Match what you see, then jump to its fix

    1. 1The message prints the path from your asset: line, and ls cannot find itThe file is not at the path written in pubspec.yamlFix
    2. 2The file exists, the path is right, and the build still cannot find the entry; or you see 'unable to find directory entry' for a folder you declaredThe fonts block is nested under the wrong keyFix
    3. 3Fonts or images in a sub-folder are missing at run time, or a declared folder has no matchA folder entry only covers files directly inside itFix

What does the error look like?

  • Error: unable to locate asset entry in pubspec.yaml: "assets/fonts/Lato-Regular.ttf".
  • Error: unable to find directory entry in pubspec.yaml

Cause 1 of 3

The file is not at the path written in pubspec.yaml

1Check

The value of asset is a relative path from the folder that contains pubspec.yaml. Check spelling, upper and lower case, the extension and the folder name. A font that sits in lib/ or in a sub-project is not found by a path written from the root.

find . -iname 'Lato-Regular*' -not -path './build/*'

2Fix

Move the file to the path you declared, or change the asset: line to the real path.

flutter:
  fonts:
    - family: Lato
      fonts:
        - asset: assets/fonts/Lato-Regular.ttf

3Verify

Fetch dependencies and build again.

flutter pub get
flutter build apk --debug

Confirmed by docs.flutter.dev

Did this fix it?

Cause 2 of 3

The fonts block is nested under the wrong key

1Check

Indentation in YAML is meaning. In the Flutter docs, fonts: sits under flutter:, each family under fonts:, and the file list under the nested fonts:. The assets guide states that assets: must be indented by exactly two spaces below flutter:, and says the directory error can point to bad indentation.

sed -n '/^flutter:/,$p' pubspec.yaml | cat -A | head -30

2Fix

Re-indent the block to match the documented structure, using spaces and not tabs.

flutter:
  uses-material-design: true
  assets:
    - assets/images/
  fonts:
    - family: Lato
      fonts:
        - asset: assets/fonts/Lato-Regular.ttf
        - asset: assets/fonts/Lato-Bold.ttf
          weight: 700

3Verify

Run the build again.

flutter pub get && flutter run

Confirmed by docs.flutter.dev

Did this fix it?

Cause 3 of 3

A folder entry only covers files directly inside it

1Check

An assets: entry that ends with / bundles the files directly in that folder. Files in its sub-folders are not included unless the sub-folder has its own entry.

find assets -type f | head -30
grep -n 'assets/' pubspec.yaml

2Fix

Add one line for every folder that holds assets, and list every font file under its family with its own asset: line.

flutter:
  assets:
    - assets/images/
    - assets/images/icons/

3Verify

Stop the app and start it again, since changed assets are not picked up by hot reload.

flutter run

Confirmed by docs.flutter.dev

Did this fix it?

How do I stop it coming back?

  • Keep fonts in one folder such as assets/fonts and declare every file by name.
  • Run flutter pub get after every pubspec.yaml edit and read its output.
  • Use two-space indentation and set your editor to show whitespace in YAML.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

Google Play says the app does not support 16 KB memory pages

check_elf_alignment.sh reports UNALIGNED for a library under lib/arm64-v8a

Google Play requires apps that target Android 15 or higher and ship native .so libraries to run on devices with 16 KB memory pages; from 1 February 2027 it will block updates that do not.

5 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.