Mac 升级macOS Monterey12.3 Flutter项目运行报错解决方案

823 阅读1分钟

Android报错信息

Could not find tools.jar.Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.

Could not find tools.jar.

Please check that

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

contains a valid JDK installation.

步骤一:配置JDK环境

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home

export PATH=$JAVA_HOME/bin:$PATH

步骤二:复制一份tools.jar

/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/lib/tools.jar

Copy 一份到

/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib

下

IOS报错信息

实际上

截屏2022-03-16 22.59.44.png 结果报错

截屏2022-03-16 23.00.21.png

Warning: CocoaPods not installed. Skipping pod install.
  CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
  Without CocoaPods, plugins will not work on iOS or macOS.
  For more info, see https://flutter.dev/platform-plugins
To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

方案一:安装android studio bumblebee

方案二:卸载cocoapods,安装cocoapods

1.卸载cocoapods

sudo gem uninstall cocoapods

查看本地安装过的cocopods相关东西

gem list --local | grep cocoapods
我的显示
cocoapods-core (1.9.1)
cocoapods-deintegrate (1.0.4)
cocoapods-downloader (1.3.0)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.0)
cocoapods-stats (1.1.0)
cocoapods-trunk (1.4.1)
cocoapods-try (1.1.0)

使用命令逐个删除
例如
sudo gem uninstall cocoapods
sudo gem uninstall cocoapods-core

2.安装cocoapods

sudo gem update --system
sudo gem install cocoapods --pre

如果报错

LoadError - dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle, 0x0009): missing compatible arch in /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle - /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle

解决它首先找到finder(访达),然后找到"应用程序"选项,在找到实用工具文件,点击进去找到"终端",然后右键点击它,选中"显示简介",你会发现一个选项"使用Rosetta打开",对问题的关键就是这个选项,要勾选它,关闭后重启终端后你还要输入命令让它生效,命令如下:

sudo gem install ffi

然后你再去执行pod命令

pod search AFN

3: 转到Flutter项目的iOS目录,重启软件就好了

pod install