"flutter pub get" A required privilege is not held by the client - flutter

I keep getting this error on Android Studio flutter project, although flutter doctor command shows no issues!
Cannot create link, path = 'C:\Users\UserName\AppData\Local\Pub\Cache\_temp\dir90f89940\ios\Classes\FLTFirebaseAuthPlugin.m'
(OS Error: A required privilege is not held by the client.
, errno = 1314)
pub get failed (66; , errno = 1314))
I tried with pub upgrade which seams to get dependencies correctly and start updating them, but I didn't know why pub get give this error.
Update
A workaround seems to be running Android Studio as administrator!

I have switched ON developer mode in Windows settings (Settings -> Update & security -> For developers) . It worked for me.
Like so:

I'm using vscode I just opened it as administrator and everything works fine.

If you are using Android Studio:
open Android Studio with "Run as administrator"

Just run your PowerShell in administrator mode
the
cd to your project and run
flutter pub get

I wanted to add this solution because when you have accounts managed by your company this is a common problem.
Just go to your quick acces in Start then:
Right Click > More > Open File Location
When the Explorer Opens Right Click again on the AS Icon (quick access), then:
Properties > Advanced ... > Run as Administrator
So you can run always by default as Administrator.
Regards.-

Just run your IDE whether VS Code or Android Studio as Administrator . It solves the issue

Other temporary solution is that making pub cache and then trying flutter pub get.
https://spikez.tistory.com/439
Solution :
1.  flutter pub get
 
 ==> error will be occurred.
[your flutter sdk folder]\flutter.pub-cache_temp\ dir7d36fb45\macos\Classes\FlutterBluePlugin.h' (OS Error: 지정된 파일을 찾을 수 없습니다. , errno = 2)
copy dir7d36fb45  to [your flutter sdk folder]\flutter.pub-cache\hosted\pub.dartlang.org 
change name dir7d36fb45 to flutter_blue-0.8.0
cd flutter_blue-0.8.0 (created by you)
create pubspec.yaml in flutter_blue-0.8.0 folder
fill below content in pubspec.yaml
now you have done preparing flutter_blue cache  :)
lets do, flutter pub get
maybe it will be work.
I know it is a temporary solution. but I believe it will help you understand how to work pub get..
 
If you need new pubspec.yaml ,
you can find out in here  : https://github.com/pauldemarco/flutter_blue/blob/master/pubspec.yaml

Related

Pub failed to rename directory because access was denied

Whenever I run flutter doctor or flutter pub get, I am getting the following error
Pub failed to rename directory because access was denied.
This may be caused by a virus scanner or having a file in the directory open in another application.
Running "flutter pub get" in flutter_tools...
pub get failed (1; in the directory open in another application.)
I have tried some commands, ran the commands in administrator mode, but still getting the same error.
For me it helped to delete the 'pubspec.lock' file in the project folder and the run flutter pub get again
The source of my problem was that I had flutter installed directly in the C directory. After moving it to another directory (worked for me under MyUser/Downloads) the problem was solved.
I also faced a similar problem.
so, running flutter clean in terminal solved the problem.
I have deactivated my Anti-Virus and it worked for me! - Deactivate Antivirus

Failed to start DevTools: Dart DevTools exited with code 255

I am getting this error code in my Visual Studio Code. How can I fix it?
I am using Flutter v2.5.3.
You can try fixing it by running this in the terminal:
Just copy and paste the below code into the terminal and run it.
dart pub global activate devtools -v 2.8.0
which downgrades the version to 2.8.0 (that works fine). I found the answer on GitHub.
I agree with RandomCoder's answer to avoid executing command
dart pub global activate devtools -v 2.8.0
every time before opening Visual Studio Code.
And also if you didn't know the location of the build folder mentioned by RandomCoder, I found the location after reading it here for the pub cache folder:
By default, this directory is located under . pub-cache in your home directory (on macOS and Linux), or in %LOCALAPPDATA%\Pub\Cache (on Windows). (The precise location of the cache may vary depending on the Windows version.)
After you found it, go to the \hosted\pub.dartlang.org\devtools-2.8.0 directory to copy the build version there and paste it in \hosted\pub.dartlang.org\devtools-2.9.2.
I still didn't know if there is any bad effects of copy pasting it to a newer version folder, but in my case it's working until now.
In my case there wasn’t any build folder in the devtools-2.9.2 folder.
I copied it from 2.8.0 and it now works.
For Android Studio
Close Android Studio
Rn dart pub global activate devtools -v 2.8.0 to downgrade (as suggested in a previous answer)
Open Android Studio
Run your build
For Visual Studio Code
Open Terminal
Run dart pub global activate devtools -v 2.8.0 to downgrade (as suggested a previous answer)
I fix this by:
flutter upgrade
This is an issue coming since yesterday. Maybe they must have updated the Dart engine.
There are two ways which will help you to solve the issue.
Update the Flutter SDK to the latest version and restart your PC:
flutter upgrade
Use the Dart Devtools manually
Run flutter pub global in another terminal. Run devtools and then open http://127.0.0.1:9100
Enter a running application field address of your running application in the Connect: "http://127.0.0.1:60230/J7_wS_YhTuo=/"
You can find this URL in debug console when you run the code.
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:51849/mHlycLJYEWw=/ws
If you are getting any issue regarding the port, then do this in your Flutter project console
flutter run --observatory-port=9100
Once the application starts you can see the message in the console.
If you are getting any server issue in the web browser
then enter
dart devtools
In cmd
Downgrade to devtools-2.8.0
And activate using dart pub global activate devtools -v 2.8.0
These two steps worked in my case
First activate your devtool using this command...
flutter pub global activate devtools
flutter pub global run devtools
And after that, try launching it from Visual Studio Code as described in the documentation: Install and run DevTools from VS Code

How can I fix Flutter_localizations error on the vscode? - Target of URI doesn't exist

I'm trying to use flutter_localizations and I followed this guide
When I save pubspec.yaml on vscode then pub get is ran.
After that vscode can't find app_localizations.dart file.
But this error messages will disappear when I reopen vscode.
Is there anyone with such a problem like me?
Thanks.
Use this command and Open command palette - command + shift + p on the vscode.
Type Dart: Restart Analysis Server and select it.
This error will be gone.
Usually running
flutter gen-l10n
should be enough, however sometimes I'va found myself using
flutter clean && flutter pub get dependencies && flutter packages get
To clean cache, and get the dependencies(which also generate the l10n). 95% of the time the first command should suffice

Could not resolve project :url_launcher_macos

I create new app in flutter and it's work when I run it, but when I add shared_preferences package, I got this error when I run it
Could not determine the dependencies of task ':url_launcher:compileDebugAidl'.
Could not resolve all task dependencies for configuration ':url_launcher:debugCompileClasspath'.
Could not resolve project :url_launcher_macos.
Required by:
project :url_launcher
Unable to find a matching configuration of project :url_launcher_macos:
- None of the consumable configurations have attributes.
Neither package is compatible with mac
I have faced the same problem and i have fixed this with running following command:
flutter pub cache repair
If this is not working then please try the following:
flutter channel stable then run the commands
flutter clean and flutter upgrade
This worked for me
NOTE:- CLOSE THE FLUTTER PROJECT
Go to Flutter sdk path
Enable the view hidden files in Mac by using CTRL + SHIFT + .
Go to .pub-cache
Go to hosted
Go to pub.dartlang.org
delete this folder url_launcher_macos
Open the project and run app

new flutter project in vscode has error

when i create a new flutter project in vscode it will immediately shows an error in the main.dart file and gives a gradle error when trying to debug.
shown here: main.dart error
"compiler message: lib/main.dart:68:19: Error: Too few positional arguments: 1 required, 0 given."
I've reinstalled dart and flutter plugins. updated the java install.
in debug console i get this:
debug console
added output of flutter doctor -v
enter image description here
I was also facing the same error, but it was always on my test folder.
This is what I did:
On your terminal, make sure you are in your project repository.
Run the flutter pub get command, it worked for me, may be you
should try it too.
Do you possibly have two different versions of the Flutter SDK on your machine? I wonder if one is being used by flutter create and the other for analysis.
If you're sure you only have one, please open an issue on GitHub and attach a log file for me to investigate.