Mac m1 Flutter安装环境配置

masOS13.5,  xcode14.3.1  Flutter3.10.6

安装软件:xcode/Android Studio/google浏览器

下载flutterSDK,配置环境变量

在终端执行open ~/.bash_profile命令,打开bash_profile文件,如果没有则执行touch ~/.bash_profile进行创建,然后将以下命令添加到bash_profile文件中

export PUB_HOSTED_URL=https://pub.flutter-io.cn//国内用户需要设置

export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn//国内用户需要设置

export PATH=`pwd`/flutter/bin:$PATH

注意这里的`pwd`/flutter就是上一步中将sdk拷贝到自己系统的路径

4、添加flutter相关工具到path中,在终端输入命令【open ~/.zshrc】,如果报错【The file /Users/personal/.zshrc does not exist.】,说明还没有创建.zshrc文件,需要先运行【vim ~/.zshrc】创建.zshrc文件,然后再运行【open ~/.zshrc】,具体操作如下所示:

personal@MacBook-Pro ~ % open ~/.zshrc
The file /Users/personal/.zshrc does not exist.
personal@MacBook-Pro ~ % vim ~/.zshrc
personal@MacBook-Pro ~ % open ~/.zshrc

然后将以下配置复制进.zshrc里边
注意: export PATH=【此处为下载的flutter路径】/bin:$PATH

export PATH=/Users/personal/Desktop/project/flutter/bin:$PATH
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

具体显示如下图所示:

截屏2021-11-06 下午3.02.04.png

然后再运行以下命令保存.zshrc文件:

personal@MacBook-Pro ~ % source ~/.zshrc

终端输入 flutter doctor,查看是否有报错,有报错就处理报错 

Chrome - develop for the web (Cannot find Chrome executable at

    /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)

    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

安装谷歌浏览器就可以解决

[!] Android Studio (not installed)

安装Android Studio就可以解决

[!] Network resources             

    An HTTP error occurred while checking "https://github.com/": Operation

      timed out

git config --global http.proxy http://127.0.0.1:7890

git config --global https.proxy http://127.0.0.1:7890

设置这两个代理就可以解决

[✗] 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.

安装Android Studio后,应用Android SDK就可以解决

[✗] Android toolchain - develop for Android devices ✗ Unable to locate Android SDK. Mac终端配置报错问题解决 - 简书

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值