The flutter tool cannot access the file

Viewed 2993

I try to run the Flutter project but there is an error

Flutter failed to write to a file at
"C:\Users\Dell\flutter-development\projects\flutter_complete_guide\ios\Runner\GeneratedPluginRegistrant.h". The flutter
tool cannot access the file.
Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current
user.

Versions:

Flutter 1.22.4,

Windows 10

I tried to create a Flutter project with cmd and android-studio but the result is the same.

I gave full permissions for ALL(Including Dell user) for flutter-sdk directory, flutter project and their subdirectories also.

Once try to build project from scratch with flutter create myapp get next error

PS C:\src1\project> flutter create myapp
Recreating project myapp...
  myapp\android\app\src\main\res\mipmap-mdpi\ic_launcher.png (created)
Failed to send crash report due to a network error: SocketException: OS Error: Access is denied.
, errno = 5, address = clients2.google.com, port = 63568
Oops; flutter has exited unexpectedly: "FileSystemException: Cannot copy file to 'C:\src1\project\myapp\android\app\src\main\res\mipmap-mdpi\ic_launcher.png', path =
'C:\src1\flutter\packages\flutter_tools\templates\app\android.tmpl\app\src\main\res\mipmap-mdpi\ic_launcher.png' (OS Error: Access is denied.
, errno = 5)".
2 Answers
Flutter failed to write to a file at
"C:\Users\Dell\flutter-development\projects\flutter_complete_guide\ios\Runner\GeneratedPluginRegistrant.h". The flutter
tool cannot access the file.
Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current
user.

Make sure that you have ownership rights over the flutter installation folder. Check this out.

OS Error: Access is denied.
, errno = 5

Error 5: Access denied is a known issue on Windows 10. This error prevents you from installing software on your computer and accessing or modifying certain files.

The reason for this issue is the non-availability of the permissions. Windows 10 will prevent you from installing if you don’t have the Administrator privileges or if your account is not the administrator account.

Getting administrator privileges for your account on the computer solves this problem.

I spent 5 days just to fix this issue.

  • i reset my windows 10 and it didn't work.
  • i upgrade to windows 11 and hoping it might takeover the permission or anything, but still didn't work.
  • until i tried to backup my flutter project to google drive and then redownload it. it ends up work.

i guess to fix this issue you just need to reset the folder attribute by recreating every file. and in my case through cloud storage.

Related