Flutter build stops: a font file in pubspec.yaml cannot be found
Error: 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:.
Fix it fast
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.yaml2Match what you see, then jump to its fix
- 1
The message prints the path from your asset: line, and ls cannot find itThe file is not at the path written in pubspec.yamlFix - 2
The 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
Fonts 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
- 1
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.ttf3Verify
Fetch dependencies and build again.
flutter pub get
flutter build apk --debugConfirmed by docs.flutter.dev
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 -302Fix
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: 7003Verify
Run the build again.
flutter pub get && flutter runConfirmed by docs.flutter.dev
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.yaml2Fix
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 runConfirmed by docs.flutter.dev
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- Qist BazaarA buy-now-pay-later marketplace built from a blank repo, now past 100K downloads on Google Play.
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 fixMobile apps
Gradle cannot find com.google.firebase:firebase-analytics-ktx
Required by: project :app
Firebase moved the Kotlin extensions into the main modules and stopped releasing the -ktx modules in July 2025.
2 causes, each with a fixMobile apps
Gradle cannot create LibraryVariantBuilderImpl in a Flutter Android build
Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl
This error appears when the Android Gradle plugin (AGP) cannot run in the Gradle or IDE you use.
3 causes, each with a fixMobile apps
Flutter release build cannot open the keystore: HmacPBESHA256 not available
Algorithm HmacPBESHA256 not available
The keystore is a PKCS12 file protected by a newer algorithm than the Java that is reading it understands.
3 causes, each with a fixMobile apps
Android install error: the package conflicts with an existing package of the same name
The package conflicts with an existing package by the same name
Android allows only one app per application ID, and an update must be signed with the same certificate as the installed version.
3 causes, each with a fixMobile apps
Android resource linking fails with resource android:attr/lStar not found
error: failed linking references.
The lStar attribute exists only from Android API 31.
2 causes, each with a fix