Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 799
C.Calzana Avatar asked Jan 09 '20 04:01

C.Calzana


3 Answers

In my case, the problem was that I was missing slash /.

At first, I have added my icons path as below.

  assets:
      - assets/icons

I solve the issue by adding as slash / to the end of the path as below:

  assets:
      - assets/icons/
like image 93
Nipun Ravisara Avatar answered Oct 24 '22 13:10

Nipun Ravisara


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

assets:
 - assets/credentials.json // <-- count three spaces from start
like image 28
Darshan Avatar answered Oct 24 '22 12:10

Darshan


I was facing the same problem, and I had two mistakes:

  1. I created the "images" folder inside the "lib" folder, and it should be outside the lib folder, it should be in the app root folder. enter image description here

  2. It should be three spaces from the starter line as @Darshan said

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

    It should appear a grey line, like this

    enter image description here

like image 21
Sana'a Al-ahdal Avatar answered Oct 24 '22 13:10

Sana'a Al-ahdal