zl程序教程

您现在的位置是:首页 >  其他

当前栏目

Flutter 出错处理

2023-04-18 12:28:47 时间
[!] An error occurred while processing the post-install hook of the Podfile.
undefined method `each_child' for #<Dir:0x00007fd6c037b538>

应该是cocoapods上出错,

google后得知 cocoapods的版本应该在 1.9.0 以上

升级后,无效

再查 是ruby 的版本应该在 2.6.0 及以上

这里使用rvm 来切换版本

rvm install 2.6.0

中间也是出现了一堆各种各样的问题,

安装时,让我先升级 brew ,执行brew update 又出错,让我去 unshallow,

然后 执行时又被网络卡住,

更换 brew 的镜像 参考:https://www.jianshu.com/p/77c60428569d 换 清华的源

接下来,一切顺利了。

再次执行 pod install 正常了。

后来发现,在VSCode中出错,也是因为没有切换到 ruby 2.6.0版本的问题。

应该在VSCode中设置一下,但找了一圈没找到哪里可以更改当前项目的。

那就改系统的

rvm --default use 2.6.0

不是很好,但暂时能用了

2. Error: Cannot run with sound null safety, because the following

dependencies don't support null safety:

有些包不支持 safety模式,暂时不用

flutter run --no-sound-null-safety

正常

如果使用VSCode 的话, 需要在launch.json中添加同样的参数

"version": "0.2.0",
  "configurations": [
    {
      "name": "flutterapp",
      "request": "launch",
      "type": "dart",
      "args":["--no-sound-null-safety"]
    }
  ]