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

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

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/

Check identation of assets. Generally it should have 3 spaces from start of new line.
assets:
- assets/credentials.json // <-- count three spaces from start

I was facing the same problem, and I had two mistakes:
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.
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

there are 2 possibility
Folder/file missing in your project directory
Missing "/" in the end of folder/file name in pubspec.yaml file

try copying the file manually not using VS-Code or Android studio. don't use drag/drop.

You need mention as
assets:
- assets/icons/
in pubspec.yaml

I had this same problem, I was able to fix it by using only the name of directory created in the projects root folder, instead of also including the file i was trying to point to.
assets:
- images/
is what worked for me instantly, just point to the whole dir and specify the file name in ImageAssets object.

Sometimes you need to enter filename as such:
flutter: assets:
- lib/assets/logo.png

I was facing the same problem, and I had two mistakes:
When I add lib in assets then I solve my problem.
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:
- lib/images/background.jpg

Related

How do I exclude a folder from the sidebar in Sublime Text permanently, specifying it relative to the open folder?

I've already read this related question (How do I exclude a folder from search in sublime text 3 permanently?) but my question is different since I want to specify only the folder at the open folder's root, not a generic pattern to match at any level in the folder tree.
In Sublime Text 4 I have an open project folder via File --> "Open Folder...".
Let's say my folder layout is this:
mainapp
├── microapp
│ └── node_modules <== don't exclude this (keep it)
├── microapp2
│ └── node_modules <== don't exclude this (keep it)
├── index
├── node_modules <=== exclude this only
├── config
└── assets
I'd like to exclude mainapp/node_modules only, NOT mainapp/microapp/node_modules nor mainapp/microapp2/node_modules. How do I do that?
I'm guessing I need to specify a "folder_exclude_patterns" in the settings.
Side note: why do I need to do this?
Because that folder has so much build content in it (which is constantly-changing as builds occur) that it's actually causing Sublime Text to freeze and lock up and become unusable.
Tested on Linux Ubuntu 18.04.
Through sheer dumb luck and persistence with guessing, I figured it out. // refers to the "open folder root", apparently.
If you want to see this info about // added to the official Sublime Text documentation and default settings file, please upvote my open issue on it here.
Update
I found some official documentation on this: https://www.sublimetext.com/docs/file_patterns.html. The // feature was added as of Sublime Text 4:
If pattern begins with //, it will be compared as a relative path from the project root [added in version 4.0]
My testing, however, proves that the // actually means "path" root, as defined below, however. So, my examples below are still correct.
1. If you have a folder open via File --> "Open Folder...", do this:
Preferences --> Settings --> add this "folder_exclude_patterns" entry to your user settings JSON file:
{
// other user settings here
// exclude only the "mainapp/node_modules" dir
"folder_exclude_patterns": ["//node_modules"],
// other user settings here
}
Again, // means the "open folder's root".
NOTE: Changing your user settings above will apply globally to all of your Sublime Text instances, which may not be what you want. So, it may be better to use a "Project" instead, as described below:
2. If you have the folder open and saved as part of a project, do this:
Project --> Edit Project --> add this "folder_exclude_patterns" entry to your Project settings JSON file:
{
"folders":
[
{
// path to an open folder in a project
"path": "/path/to/mainapp",
// exclude only the "mainapp/node_modules" dir
"folder_exclude_patterns": ["//node_modules"],
}
],
}
You can see in the official project settings file example here (https://www.sublimetext.com/docs/projects.html) that the "folder_exclude_patterns" entry must be at the same level in the JSON settings file as the "path" entry.
I also first learned this from #smhg's comment here. Thank you!
To open another folder in your project, go to Project --> "Add Folder to Project...". Once you have multiple folders open in your project, you'll have to add multiple entries of "folder_exclude_patterns", as desired, like this:
{
"folders":
[
{
// **absolute path** to open a folder in a project
"path": "/path/to/mainapp",
// exclude only the "mainapp/node_modules" dir
"folder_exclude_patterns": ["//node_modules"],
},
{
// or **relative path** to open another folder in the project;
// the path is relative to the location of the
// "project_name.sublime-project" project file itself
"path": "some_dir",
// exclude only the "some_dir/path/to/excluded_folder" dir
"folder_exclude_patterns": ["//path/to/excluded_folder"],
},
],
}
Bonus: How to create a project in Sublime Text:
To create a Project from an open folder, the steps are like this:
Open a folder: File --> "Open Folder..."
Save it as part of a project: Project --> "Save Project As..."
Now you can choose where to save your project_name.sublime-project file. This is the file you are editing when you go to Project --> "Edit Project" above. To open a project go to Project --> "Open Project...".
See also:
Issue I opened: https://github.com/sublimehq/sublime_text/issues/5234
Comment I wrote on the Sublime Text forum: https://forum.sublimetext.com/t/a-way-to-specify-root-in-project-settings/7756/4?u=ercaguy
Official Project settings documentation: https://www.sublimetext.com/docs/projects.html. This includes:
Each object must have a "path" key, which may be relative to the project directory, or a fully qualified path.
How do I exclude a folder from search in sublime text 3 permanently? - answer which explains how to exclude a file or folder from the side bar in Sublime Text, versus excluding a file or folder from search, such as Goto Anything or Find in Files.

How can i keep one node_modules folder for multiple Angular projects which has same dependencies?

I like to keep one node_modules for multiple Angular projects since it does not add around 500mb data per project into my HDD - ( yes this question has been asked many times before , i tried almost all tips in them but did not work)
This is my folder structure
:~/Public/node_modules/angular/ <-- this is where contents of usual node_modules folder end up
:~/Public/angular/project1/ <- ng new -skip-install
:~/Public/angular/project2/ <- copy of above and not running above command
and i have modified the usual 2nd line of angular.json to this
"$schema": "../../node_modules/angular/#angular/cli/lib/config/schema.json",
and when i do ng serve
i get the following error
An unhandled exception occurred: Cannot find module '#angular-devkit/build-angular/package.json'
Require stack:
- /usr/local/lib/node_modules/#angular/cli/node_modules/#angular-devkit/architect/node/node-modules-architect-host.js
- /usr/local/lib/node_modules/#angular/cli/node_modules/#angular-devkit/architect/node/index.js
- /usr/local/lib/node_modules/#angular/cli/models/architect-command.js
- /usr/local/lib/node_modules/#angular/cli/commands/serve-impl.js
- /usr/local/lib/node_modules/#angular/cli/node_modules/#angular-devkit/schematics/tools/export-ref.js
- /usr/local/lib/node_modules/#angular/cli/node_modules/#angular-devkit/schematics/tools/index.js
- /usr/local/lib/node_modules/#angular/cli/utilities/json-schema.js
- /usr/local/lib/node_modules/#angular/cli/models/command-runner.js
- /usr/local/lib/node_modules/#angular/cli/lib/cli/index.js
- /usr/local/lib/node_modules/#angular/cli/lib/init.js
- /usr/local/lib/node_modules/#angular/cli/bin/ng
See "/tmp/ng-kyWfPF/angular-errors.log" for further details.
How do i get rid of this and get the functionality i desire of having one node_modules for many projects like i have mentioned above ?
If I understood correctly the node_modules and angular are on the same level, so in this case, you set incorrect path in angula.json. You need
"$schema": "./node_modules/angular/#angular/cli/lib/config/schema.json"

Package.json fields: Child directories are not ignored

I'm working on a large TS-based library. When I build the application, this creates a lot of .d.ts files, most of which are of internal use only, and make no sense to export or ship to the end user. Usually I've used a .npmignore file to keep these out, but recently learned that certain tools really prefer that information to be included via the "files" field of the package.json, so here I am trying to convert.
Now, I have a directory structure that looks somewhat like this:
dist/
--bundle.js
--...
--components/
----componentA.d.ts
----componentB.d.ts
----common/
----...
--hooks/
----...
--util/
----...
The idea is that I want all top level files, and all files directly under /components/ but no child directories. In my .npmignore, I'd do this like:
# blacklist all
**
# include whitelist
!dist/*
!dist/components/*
However, when I do the same under "files" in my package.json, all that crap still comes along. The single wildcard is not respected.
Edit:
"files": [
"dist/*",
"dist/components/*",
...
],
Reproducing what you show of your file system, this works for me:
"files": ["dist/*.js", "dist/components/*.ts"]
Omitting the file extensions indeed included all the subdirectory cruft. I tested with npm 7 and npm 6.

Copying folder except for one subfolder in Yeoman

I am working on this Yeoman project, and I am copying some files from a template to my new app directory.
This line is doing the job well:
this.fs.copyTpl(this.templatePath(''),
this.destinationPath(this.project_name_slugified+'/'));
Everything comes from the template folder and goes to the root folder of the project.
But when someone adds a flag '--nr' I want to exclude one subfolder that has been copied. So yo my-gen my_app_name --rf should copy EVERYTHING unless this subfolder.
I tried the !-glob notation, but it's not working. I did something like as first parameter:
[this.templatePath('**'),this.templatePath('!subfolder/subfolder_to_be_excluded')]
So second parameter was set to exclude the subfolder that is not necessary
I also tried deleting (delete method), but it seems that the file is not available immediately.
It's not working anyway. Any ideas? Promisifying the copyTpl would work?
By calling this.templatePath('!subfolder/subfolder_to_be_excluded'), you end up generating a broken path: /absolute/path/!subfolder/etc.
Use it without this.templatePath given you don't need the absolute path to apply the filtering.
this.fs.copyTpl(
[
this.templatePath('**'),
'!subfolder/subfolder_to_be_excluded'
],
this.destinationPath(this.project_name_slugified + '/'),
templateContext
);

Compass Sprite returning "File to import not found or unreadable"

So, I've just started using the Compass Framework, and now wish to start using its native spriting feature. In doing so, I've added the following to the top of my scss file:
#import 'compass/utilities';
#import "*.png";
#include all-img-sprites;
After compiling, I get the following error:
error path/to/my/project/css/scss/front.scss (Line 4: File to import not found or unreadable: *.png.
Load paths:
Compass::SpriteImporter
path/to/my/project/css/scss
C:/Ruby22/lib/ruby/gems/2.2.0/gems/compass-core-1.0.3/stylesheets)
Compilation failed in 1 files.
[Finished in 1.7s]
I've looked around for a solution to this, but to my surprise, even though there's multiple threads on it - I can't seem to find anything relevant.
I've tried renaming the folders thinking that the "img" folders might be keyworded or something, but to no avail. Below you'll find my config.rb.
# Set this to the root of your project when deployed:
http_path = ""
# Configure sass path
sass_path= "path\\to\\my\\project\\css\\scss"
# Folder locations
sass_dir = "css/scss"
css_dir = "css"
images_dir = "img"
fonts_dir = "fonts"
javascripts_dir = "js"
sprite_load_path = "img"
# Disable debugging comments that display the original location of your selectors
line_comments = false
Oh wait, there we go! After a bit more fiddling about.
The issue was the path. Removing the sprite_load_path from the config.rb file, and changing the above to:
#import "raw/*.png";
#include all-raw-sprites;
Works fine. Note that the img folder is still set in the config.rb.

Resources