Flutter环境变量配置

Posted 建古

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Flutter环境变量配置相关的知识,希望对你有一定的参考价值。

1、打开配置文件
方式一:vim ~/.bash_profile vim编辑
退出vim: 编辑状态下,按esc, 输入 :wq 保存退出
方式二:open ~/.bash_profile 打开配置文件 可视化编辑
2、编辑配置文件

export PATH=/Users/yangjian/Documents/Flutter/flutter/bin:$PATH
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=$PATH:/Users/yangjian/Library/android/sdk/platform-tools
export PATH=$PATH:/Users/yangjian/Library/Android/sdk/tools

其中/yangjian/Documents/Flutter/flutter/bin的是flutter sdk解压的目录

3、刷新

source ~/.bash_profile

4、检测

flutter doctor 

注:不能全局使用flutter的时候 参考下面
https://blog.csdn.net/iotjin/article/details/105629266

报错一,装jdk. http://www.java.com 这边下载安装

The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
报错二,1、配置java环境变量 参考(https://www.cnblogs.com/lude1994/p/13344681.html)
2、flutter doctor --android-licenses 每个协议都y下

[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for
      more details.

解决所有。

以上是关于Flutter环境变量配置的主要内容,如果未能解决你的问题,请参考以下文章

Flutter环境变量配置

Flutter环境变量配置

Flutter环境变量配置

Mac下如何配置环境变量

Flutter学习笔记·安装配置Flutter环境(Windows)

vscode flutter 环境搭建