Aqsa_Gul
Aqsa_Gul

Reputation: 29

Flutter failed to delete a directory at "build\flutter_assets"

I'm working on flutter to develop a "map-navigation app". I'm new to it. It showed "some of the dependencies are outdated" so I update the packages and pub files, after that the application is not running on any of the platform (i.e. Desktop, Web, android and ios). It shows the following given error.

Also tried manually deleting the build folder from the project and then executing the app, still facing the same error.

Manually deleting the build folder, applying flutter clean command then running the app still shows the error below:

image

Launching lib\main.dart on Chrome in debug mode...
Flutter failed to delete a directory at "build\flutter_assets". 
The flutter tool cannot access the file or directory.
Please ensure that the SDK and/or project is installed 
in a location that has read/write permissions for the current user.
Waiting for connection from debug service on Chrome...

Flutter failed to delete a directory at "build\flutter_assets"

I want to execute this application on web or android. Want to provide flutter tool the access to file or directory.

Upvotes: 2

Views: 11552

Answers (9)

Zayed
Zayed

Reputation: 1

Right click on the drive, select Properties. Go to security, And allow all in the permissions for everyone

Upvotes: 0

pradeepo7
pradeepo7

Reputation: 71

In my case, this error occurred because a file in the build directory was locked by another process (such as an IDE or file explorer).

I resolved the issue by manually deleting the build directory.

Upvotes: 0

Nesan
Nesan

Reputation: 11

For me, the issue occurred because the project's Windows build file was running in the background. I had to end the task in Task Manager, and then it worked.

Upvotes: 1

Bawantha
Bawantha

Reputation: 4018

For me it is because my I had not updated the .gitIgnore to avoid build folder so my git tool had included it so didn't allow to delete

Upvotes: 0

Rateb TM
Rateb TM

Reputation: 3

Go to your project's folder/build/ and delete flutter_assets. That is it!

Upvotes: -1

thobani
thobani

Reputation: 71

One of the issues could be that the project is running from C: drive, if possible you can move the project to a different drive. C: drive usually has a lot of restrictions.

Upvotes: 1

Jean-Pierre Schnyder
Jean-Pierre Schnyder

Reputation: 1934

This was my error when try to debug the Flutter app on my Android smartphone>:

Unable to delete directory 'C:\Users\Jean-Pierre\Development\Flutter\audio_learn\build\app\outputs\apk\debug' 
Failed to delete some children. This might happen because a process 
has files open or has its working directory set in the target directory.

The problem could only be solved by restarting Windows 10.

Upvotes: -1

Tahir
Tahir

Reputation: 300

For anyone who faces this issue in future, as mentioned by @GrahamD this issue is because of space in the path. In this case it's HP PC that should be HP_PC or HPPC or any valid string. Here are few ways you can troubleshoot this issue.

  • Rename the user account. Examples: mypc, my_pc, MyPc, myPC, etc.
  • Change the working directory to the path that doesn't contain space/s. Example: C:\Users\Public\ etc.
  • Create a new user with a name having no space/s.

After moving your directory, run flutter clean command and then run your project again. It should work now.

Note: You may need to install software if you create a new user account.

Upvotes: 2

GrahamD
GrahamD

Reputation: 3165

The problem is probably because it is not a good idea to have a space in the path to a flutter project ie. 'HP PC' would be better named with an underscore instead of the space character.

The flutter documentation warns you of this here https://docs.flutter.dev/get-started/install/windows

Upvotes: 3

Related Questions