在Mac 上安装flutter 遇到的问题

这篇具有很好参考价值的文章主要介绍了在Mac 上安装flutter 遇到的问题。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

准备工作

1、升级Macos系统为最新系统
2、安装最新的Xcode
3、电脑上面需要安装brew https://brew.sh/
4、安装chrome浏览器(开发web用)

下载Flutter、配置Flutter环境变量、配置Flutter镜像

下载Flutter SDK

https://docs.flutter.dev/release/archive?tab=macos
在Mac 上安装flutter 遇到的问题,前端报错bug,macos,flutter
根据自己的电脑选择arm64或x64

  1. 查看CPU型号:可以通过查看CPU型号来区分CPU是ARM还是X86,ARM的CPU型号一般以“ARM”开头,而X86的CPU型号一般以“Intel”或“AMD”开头。

  2. 查看指令集:可以通过查看CPU支持的指令集来区分CPU是ARM还是X86,ARM支持的指令集一般是ARM指令集,而X86支持的指令集一般是x86指令集。

可以通过下面的命令查询:uname -a

~ % uname -a
Darwin PhoenixdeMBP 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul  5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 arm64

把下载好的Flutter SDK随便减压到你想安装Sdk的目录如
/Users/phoenix/Documents/flutter_sdk/flutter

把 Flutter安装目录的bin目录配置到环境变量,然后把Flutter国内镜像也配置到环境变量里面

vim ~/.bash_profile
vim ~/.zshrc
export PATH=/Users/phoenix/Documents/flutter_sdk/flutter/bin:$PATH
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn			

里面的/Users/phoenix/Documents/flutter_sdk/flutter/bin,需要改为自己电脑的。在输入环境变量的时候,默认情况下是不可输的,需要按下ℹ️键,才可以输入。输入完成过后按下esc键、:键,输入wq退出。让配置环境变量生效。

flutter --version 如果能出来版本说明flutter sdk配置成功。
注意:如果配置完成后输入flutter --version告诉你flutter不是内置命令之类的错误的话,可能sdk没有配置成功,也可能sdk下载的时候没有下载全

运行flutter doctor 命令检测环境

第一次运行 flutter doctor的时候会提示下面错误

~ % flutter doctor

You have not agreed to the Xcode license agreements, please run 'sudo xcodebuild -license' from within a Terminal window to review and agree to the Xcode license agreements.
Building flutter tool...
Resolving dependencies... 
Got dependencies.
Failed to find the latest git commit date: VersionCheckError: Command exited with code 69: git -c log.showSignature=false log HEAD -n 1 --pretty=format:%ad --date=iso
Standard out: 
Standard error: 
You have not agreed to the Xcode license agreements, please run 'sudo xcodebuild -license' from within a Terminal window to review and agree to the Xcode license agreements.

Returning 1970-01-01 08:00:00.000 instead.
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel [user-branch], 0.0.0-unknown, on macOS 13.5.1 22G90
    darwin-arm64, locale zh-Hans-CN)
    ! Flutter version 0.0.0-unknown on channel [user-branch] at
      /Users/phoenix/Documents/flutter_sdk/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an
      official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions
      at https://flutter.dev/docs/get-started/install.
      Cannot resolve current version, possibly due to local changes.
      Reinstall Flutter by following instructions at
      https://flutter.dev/docs/get-started/install.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss
      this error.
[] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from:
      https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK
      components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup
      for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[!] Xcode - develop for iOS and macOS (Xcode 14.3.1)Xcode end user license agreement not signed; open Xcode or run the command
      'sudo xcodebuild -license'.Xcode requires additional components to be installed in order to run.
      Launch Xcode and install additional required components when prompted or
      run:
        sudo xcodebuild -runFirstLaunch
    ✗ CocoaPods not installed.
        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.
[] Chrome - develop for the web
[!] Android Studio (not installed)
[] VS Code (version 1.80.0)
Error executing simctl: 69

You have not agreed to the Xcode license agreements, please run 'sudo xcodebuild
-license' from within a Terminal window to review and agree to the Xcode license
agreements.


[] Connected device (2 available)
[!] Network resources             
    ✗ An HTTP error occurred while checking "https://github.com/": Connection
      closed before full header was received

! Doctor found issues in 5 categories.

这里如果这里没有安装 brew 的需要安装,安装方法可以参考
https://editor.csdn.net/md/?articleId=132603606

分根据报错信息分别执行下面命令

brew install cocoapods
pod setup
sudo xcodebuild -runFirstLaunch

在执行:brew install cocoapods报错

~ % brew install cocoapods
Error: You have not agreed to the Xcode license. Please resolve this by running:
  sudo xcodebuild -license accept

在这里是因为Xcode没有打开激活,只需要,打开Xcode,同意各种协议,即可在终端安装应用程序了。

依次执行:

brew install cocoapods
pod setup
sudo xcodebuild -runFirstLaunch

这次brew install cocoapods 成功了

再次执行:~ % flutter doctor 遇到下面的问题

An HTTP error occurred while checking "https://github.com/": Connection
      closed before full header was received

后面翻墙再次执行~ % flutter doctor

~ % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[] Flutter (Channel stable, 3.13.2, on macOS 13.5.1 22G90 darwin-arm64, locale
    zh-Hans-CN)
[] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from:
      https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK
      components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup
      for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[] Chrome - develop for the web
[!] Android Studio (not installed)
[] VS Code (version 1.80.0)
[] Connected device (2 available)
[] Network resources

! Doctor found issues in 2 categories.

最后一个报错android studio官网下载软件就可以了
https://developer.android.google.cn/studio/

% flutter doctor                   
Doctor summary (to see all details, run flutter doctor -v):
[] Flutter (Channel stable, 3.13.2, on macOS 13.5.1 22G90 darwin-arm64, locale
    zh-Hans-CN)
[] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[] Chrome - develop for the web
[] Android Studio (version 2022.3)
[] VS Code (version 1.80.0)
[] Connected device (2 available)
[] Network resources

• No issues found!

你认真做好一件事,会解释所有事。O(∩_∩)O文章来源地址https://www.toymoban.com/news/detail-698177.html

到了这里,关于在Mac 上安装flutter 遇到的问题的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 实例解释遇到前端报错时如何排查问题

    前端页面报错: 1、页面报错500,首先我们可以知道是服务端的问题,需要去看下服务端的报错信息: 2、首先我们查看下前端是否给后端传了id: 我们可以看到接口是把ID返回了,就需要再看下p_id是什么情况了。 3、我们再次请求,把p_id进行打印,看下具体是什么: put接口代

    2024年04月16日
    浏览(29)
  • mac安装VsCode遇到的问题

        万事开头难,头一次在安装生产工具的时候,就遇到了这么棘手的问题。百度和Google都试过了,网上的所有方式对我都没效果。最终自己阴差阳错解决了,我看内外网反馈这个问题的还挺多,在这里记录一下,希望可以帮到有缘人。     首先,我兴致勃勃地去官网下载了

    2024年02月10日
    浏览(45)
  • mac elasticsearch下载安装和遇到问题处理

    https://www.elastic.co/downloads/elasticsearch 把下载的.tar.gz文件解压到自己设定的目录下 cd /Users/电脑用户名/你的解压目录下/elasticsearch的版本/bin目录下 在bin目录下 执行./elasticsearch http://localhost:9200 如果显示json格式数据成功了 手动修改config文件中的elasticsearch.yml 搜索xpack.security.ena

    2024年02月11日
    浏览(47)
  • Mac 安装Photoshop遇到一系列问题&解决方法

    各类安装报错提示的解决方案 问题一: 安装PS提示“ 无法打开,因为apple无法检查其是否包含恶意软件 ”解决方法: 打开电脑的“终端”程序 输入以下命令: (终端位置在:启动台-其他文件夹处) sudo spctl --master-disable (代码可以全选后快捷键:command+C复制 command+V粘贴进

    2024年02月05日
    浏览(34)
  • mac安装nvm管理工具遇到的问题和解决方法

    nvm 是一款可以管理多版本node的工具,因为是刚买没多久的电脑+之前用的都是windows,昨天折腾了一下午终于倒腾好了 第一步: 卸载电脑已有的node;访问nvm脚本网址,另存为到电脑上任何目录,我是放在桌面上的https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh 第二步: 打开

    2024年02月13日
    浏览(34)
  • Mac M1通过homebrew安装Redis报错(perl: unknown or unsupported macOS version: :dunno)

    升级homebrew,命令如下: 通过命令 brew install redis 安装Redis,异常如下: 参考博文MAC 升级后brew报错后,运行命令 brew update-reset ,结果如下: 查看homebrew版本( brew --version ),结果为: 最终解决 上述 brew update-reset 升级命令即为该问题的解决办法。homebrew升级完成后,重新运行

    2024年02月07日
    浏览(49)
  • [万能办法] Mac安装pkg包报错:安装失败 “安装器遇到了一个错误,导致安装失败,请联系软件制造商以获得帮助

    打开终端,输入: sudo spctl --master-disable 然后输入锁屏密码。 然后在【系统偏好设置】-【安全性与隐私】-【通用】-【允许从以下位置下载的应用】中选择「任何来源」,然后再安装。如果依然安装失败可以重启电脑后再试一次。 sudo installer -pkg xxx.pkg -target /Applications/ 然后输

    2024年02月11日
    浏览(57)
  • 前端开发中遇到的小bug--解决方案

    1.在 searchBox 搜索栏中,用到了多级下拉框的筛选条件,样式如下:  这样看起来是没什么问题的,但当我选择时,在框中显示的内容和筛选条件的内容就出错了: 这里其实是选择了 采矿业 -- 石油和天然气开采业 ,但显示框中是 林业,筛选条件的内容也有问题: 这里没有显

    2024年02月10日
    浏览(28)
  • 【面试题】:前端怎么实现权限设计及遇到的bug

    一.权限的概念         前端权限分为页面权限、按钮权限、API权限。 二.页面权限的实现过程         ①用户登录进去调用获取用户信息接口,后端会给我们返回一个权限标识符         ②在获取到数据之后,我们就要判断用户能访问到哪些页面,我们可以在vuex中

    2024年02月11日
    浏览(38)
  • 在Mac上卸载系统安装的Git时遇到无法删除的问题的解决方法

    在Mac上,系统已经预装了Git,但如果你想卸载系统安装的Git并使用其他版本或从头开始安装,可能会遇到无法删除的问题。下面是解决这个问题的几种方法: 重要提示:在执行任何操作之前,请确保你明确了解操作的风险,并且在进行任何更改之前备份重要数据。慎重决定是

    2024年02月13日
    浏览(37)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包