android-studioflutterdart

Getting "No file or variants found for asset" found error on my asset


I am getting this attached error when I try and run my app. Any ideas? (Below)

Launching lib\main.dart on SM J200Y in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\apk\debug\app-debug.apk.
Error detected in pubspec.yaml:
No file or variants found for asset: assets/credentials.json.

I have checked the yaml file and the formatting seems to be fine. I am at a loss as want the issue is. (Also, below)

flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true
  # To add assets to your application, add an assets section, like this:
  assets:
  - assets/credentials.json

Solution

  • Check identation of assets. Generally it should have 3 spaces from start of new line.

    assets:
     - assets/credentials.json // <-- count three spaces from start