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盘的根目录,不要放在D:\android\flutter 这样的子目录,正确方法放这样的跟目录,比如C:/flutter或者 D:/flutter。
立马解决问题。也没有McAFee关掉,就解决问题了。

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值