一、配置下载SDK环境变量
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
百度说为了不翻墙的情况下下载快
如图
二、下载flutter SDK
用git bash工具进到存放sdk的文件夹中,然后输命令
git clone https://github.com/flutter/flutter.git
三、再配置sdk环境变量
看图,记得改为自己的路径
四、打开cmd命令窗口下载些依赖
进入flutter安装目录或者Flutter安装目录的flutter文件下找到flutter_console.bat,双击运行并启动flutter命令行后输入:flutter doctor
如发生错误:Error: Unable to find git in your PATH
解决方案:
在系统的环境变量Path中增加(注意找到你的git的相应目录):
- C:Program Files (x86)Gitbin
- C:Program Files (x86)Gitmingw64libexecgit-core
否则等待完成。。
正常会报错:
1:Some Android licenses not accepted. To resolve this, run: flutter doctor –android-licens
解决方案:flutter doctor –android-licenses 记得一路Yes
2错:
这个不用管,在android studio中搜索flutter插件安装即可
问题1:运行时如果发现找不到No connected devices found; please connect a device, or see flutter.io/setup for getting started instructions
解决方案:输入命令flutter doctor
是不是出现
[✗] 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_HOME变量,变量值是你Android sdk的路径
如下图:
添加完变量后,最好重启下电脑
问题2:Could not find io.flutter:flutter_embedding_debug
这个好坑,一直运行不到手机。它是报下载失败,各种改配置,换网络环境都不可以。
我猜是Android studio升级的问题的,原来是3.4配的flutter,在3.5就有问题了。
解决方法:删掉flutter重新下载就是重复上面步骤2
每次更新Android Studio版本
1、先升级AS里面的plugin的flutter,dart版本
2、删除之前下载在sdk中的flutter,重新本文开始的flutter安装
正常这样安装就可以了。有问题可评论回复