Flutter项目运行报错,flutter pub get一直通不过

项目场景:

搭建好Flutter开发环境后, 运行里面的example没问题,但是运行我们商汤公司的项目,就一直在flutter pub get那一步给卡住


问题描述:

报的问题如下
Running "flutter pub get" in babymonitor_flutter...
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.
pub get failed (1; in the directory open in another application.)
Process finished with exit code 1


原因分析:

看文字的大改意思就是没权限,可是我怎么操作去赋予权限,一直没解决问题,在Google找解决方案找了一两天。 比如一下的网页的方案,几乎都试了一遍,什么flutter pub repair呀, 什么重装开发环境呀,什么赋予权限呀! 比如什么翻墙呀,设置代理呀!比如什么设置中国镜像呀! 但是最后还是没解决问题。

https://github.com/dart-lang/pub/issues/1798
https://github.com/flutter/flutter/issues/40331
https://stackoverflow.com/questions/67578189/pub-failed-to-delete-entry-because-it-was-in-use-by-another-process

最终还是在这个网址上找到了解决问题的办法,不过居然还是葡萄牙语言:https://cursos.alura.com.br/forum/topico-erro-pub-failed-to-rename-directory-because-access-was-denied-ao-executar-comando-flutter-144008

为了做出我的贡献,避免其他码农跟我一样踩坑,我把上面那些GitHub的issue和Stack Overflow都回答了一遍。


解决方案:

解决方式很简单,flutter就放在d盘或者c盘,比如C:/flutter或者 D:/flutter。
立马解决问题。也没有McAFee关掉,就解决问题了。

你可能感兴趣的:(Flutter项目运行报错,flutter pub get一直通不过)