Maaz Zindani

Loading the index…

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

flutter build stops with 'No file or variants found for asset'

ErrorError detected in pubspec.yaml:

Short answer

The build checks every entry under flutter: assets: in pubspec.yaml. It fails when the listed file does not exist and no 2.0x or 3.0x variant exists either. So the entry points at a file that is not there. Copy the exact path from the error and list it. If the message names a package, the missing file is in that dependency.

  • Applies to Flutter 3.50 stable, Dart 3.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Take the path from the error and check whether that exact file exists, relative to the folder that holds pubspec.yaml.

    ls -l assets/images/logo.png
    grep -n "assets" -A 6 pubspec.yaml
  2. 2Match what you see, then jump to its fix

    1. 1No file or variants found for asset: <path> with no package line after itThe listed path does not match a real fileFix
    2. 2This asset was included from package <name>.The missing file belongs to a dependency, not your appFix

What does the error look like?

  • Error detected in pubspec.yaml:
  • No file or variants found for asset: assets/images/logo.png.
  • This asset was included from package

Cause 1 of 2

The listed path does not match a real file

1Check

The entry is read from the folder containing pubspec.yaml. A wrong folder name, a missing extension, a renamed file or a file that was never committed all leave the entry pointing at nothing. List the folder and compare.

ls -R assets | head -40
git status --short assets

2Fix

Correct the entry so it is the exact path of an existing file, or restore the file. To bundle a whole folder list it with a trailing slash; files directly inside are included, subfolders are not.

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

3Verify

Refresh packages and build again.

flutter pub get
flutter build apk --debug

Confirmed by docs.flutter.dev

Did this fix it?

Cause 2 of 2

The missing file belongs to a dependency, not your app

1Check

Flutter prints that line when the bad entry is in another package's pubspec. Your own assets are fine; the dependency lists a file its published copy does not contain.

flutter pub deps | grep -i "<name>"
flutter pub outdated

2Fix

Upgrade the named package to a version that ships the file. If the newest release still fails, pin an earlier working version in pubspec.yaml, or report it to the package maintainer.

flutter pub upgrade <name>
flutter clean
flutter pub get

3Verify

Build again; the 'included from package' line should no longer appear.

flutter build apk --debug

Confirmed by raw.githubusercontent.com

Did this fix it?

How do I stop it coming back?

  • List asset folders with a trailing slash and add each subfolder as its own line.
  • Run flutter build once in CI so a missing file fails the pipeline, not a release.
  • Add the folder to git together with the pubspec.yaml change, so a clean checkout has the file.

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

Next step

Want this handled for good?

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