一、安装flutter2.0.5
1、下载地址:flutter_windows_2.0.5-stable
2、解压后的目录结构(解压到${baseDir}=D:\installspace\):
3、配置系统环境变量:将${baseDir}\flutter\bin配置到path里
4、官方文档建议配置两个变量,用于下载镜像代理:参考 Flutter中文网
5、运行flutter_console.bat: 命令路径:${baseDir}\flutter\flutter_console.bat
D:\installspace\flutter>flutter_console.bat
WELCOME to the Flutter Console.
===============================================================================
Use the console below this message to interact with the "flutter" command.
Run "flutter doctor" to check if your system is ready to run Flutter apps.
Run "flutter create <app_name>" to create a new Flutter project.
Run "flutter help" to see all available commands.
Want to use an IDE to interact with Flutter? https://flutter.dev/ide-setup/
Want to run the "flutter" command from any Command Prompt or PowerShell window?
Add Flutter to your PATH: https://flutter.dev/setup-windows/#update-your-path
===============================================================================
6、运行flutter doctor命令:检查是否正常安装
Running "flutter pub get" in flutter_tools... 7.5s
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.5, on Microsoft Windows [Version 10.0.18363.1440], locale zh-CN)
[X] Android toolchain - develop for Android devices
X 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/windows#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.
[√] Chrome - develop for the web
[!] Android Studio (not installed)
[√] IntelliJ IDEA Ultimate Edition (version 2020.3)
[√] VS Code (version 1.55.2)
[√] Connected device (2 available)
检查失败,提示Unable to locate Android SDK,需要安装Android Studio。
二、安装Android Studio 4.1.3
1、下载地址 android-studio-ide-201.7199119-windows
2、Android Studio安装目录【需要1.6G空间】: D:\installspace\Android Studio
3、Android SDK 安装目录【需要4.5G空间】:
SDK Folder: C:\Users\xps\AppData\Local\Android\Sdk
下载的插件包括:Android Emulator、Android SDK Build-Tools 30.0.3、Android SDK Platform 30、Android SDK Platform-Tools、Android SDK Tools、Google APIs Intel x86 Atom System Image、Intel x86 Emulator Accelerator (HAXM installer)、SDK Patch Applier v4、Sources for Android 30
再次在命令行控制台运行flutter doctor命令,检查是否正常安装,按提示执行对应的命令。
Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses。
三、安装 VS Code
我们选择VSCode作为开发工具,安装flutter插件,如下图所示。
四、创建第一个App项目
(1) 创建步骤
(2)启动模拟器
(3)启动调试
如果调试时报连接不上的错误,查看一下项目工程目录下的编译工具配置文件:\android\gradle\wrapper\gradle-wrapper.properties
distributionUrl=https://services.gradle.org/distributions/gradle-6.7-all.zip
(4)模拟器效果