参考资料如下:
1、http://doc.flutter-dev.cn/get-started/install/
2、https://www.jianshu.com/p/603649a02956
开始我的安装:
1、下载flutter
git clone -b beta https://github.com/flutter/flutter.git
2、配置环境变量
(1)在终端命令行执行:open -e .bash_profile
(2)在打开的文件中输入如下:
#下载的flutter 路径
export M3_HOME=/Users/zhaoyanli/Android/flutter
export PATH=$PATH:$M3_HOME/bin
关闭文件,并执行第三步
(3)在终端命令行执行: source .bash_profile
3、判断是否环境变量配置成功
在终端命令行执行:flutter
如下结果
如果显示:.bash not found flutter command
查看环境变量配置,并重新配置,可参考 https://blog.****.net/hlllmr1314/article/details/52228672。
4、在终端命令行执行:flutter doctor
(1)问题
解决:
flutter upgrade
(2)问题:如未遇到可跳过
[✗] 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.io/setup/#android-setup for detailed instructions).
If Android SDK has been installed to a custom location, set $ANDROID_HOME to that location.
解决:安装android studio并且设置好$ANDROID_HOME这个环境变量。
(1)官网 2.2.3 自带gradle版本和jdk8版本
下载地址:https://developer.android.com/studio/index.html?hl=zh-cn
或者:http://www.android-studio.org/
(2)正常安装、下载sdk
(3)配置sdk环境变量
1)启动终端Terminal
2)进入当前用户的home目录
输入cd ~
3)创建.bash_profile
输入touch .bash_profile
4)编辑.bash_profile文件
输入open -e .bash_profile
因为是为了搭建Android开发环境,输入Android SDK下的tools目录:
注意 :sdk环境变量配置由于打包特殊需要必须使用ANDROID_HOME
export ANDROID_HOME=/Users/xxx/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME:$ANDROID_HOME/build-tools:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
5) 保存文件,关闭.bash_profile
6)更新刚配置的环境变量
输入source .bash_profile
(4)判断是否配置正常
执行:$ android
出现SDK 安装窗口
执行:$ adb -version
(3)问题
[✓] Android Studio (version 3.1)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
解决:android studio里还少了两个插件。我们打开andriod studio。
(1)点击preferences
image
(2)搜索plugins + 搜索flutter
(4)点击安装
有弹框提示要安装dart,同意。等安装好后重启andriod studio。
参考链接:https://www.jianshu.com/p/603649a02956