本机环境win10 , 已装 Android studio 3.2
1.下载flutterSDK。选择的Stable channel (Windows)最新版 v1.20.1
2.下载后直接解压,我解压到 D:\flutter
3.配置flutter的环境变量。
控制面板 -> 用户帐户 -> 用户帐户 -> 更改我的环境变量,
如下:
-
FLUTTER_STORAGE_BASE_URL
值:https://storage.flutter-io.cn
-
PUB_HOSTED_URL
值:https://pub.flutter-io.cn
- 在Path变量下添加 Flutter的路径,我的是
D:\flutter\bin
4.cmd 指令
flutter doctor
显示:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.20.1, on Microsoft Windows [Version 10.0.14393], 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, set ANDROID_SDK_ROOT to that location.
You may also want to add it to your PATH environment variable.
[√] Android Studio (version 3.2)
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
解释:如果Android SDK安装到自定义位置,请将Android_SDK_ROOT
设置为该位置,将其添加到PATH环境变量中。
解决:桌面右键 我的电脑>属性>高级系统设置>环境变量>在用户变量中新建Android_SDK_ROOT,变量值就是Android SDK路径。
5.cmd 指令
flutter doctor
显示:
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
X Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit
https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions.
[√] Android Studio (version 3.2)
解释:需要同意相关协议
解决:cmd: flutter doctor --android-licenses
一直Y
此时: flutter doctor
全绿
6.安装ADB。
ADB下载链接:http://adbshell.com/upload/adb.zip
下载好后直接把文件解压,我的:C:\Windows\system
,包含:( adb.exe,AdbWinApi.dll,AdbWinUsbApi.dll ),并在PATH中配置环境变量。
7.ADB运行出错:
cmd命令:adb devises
server version (31) doesn't match this client (41); killing...
解决:查看5037端口谁在占用:cmd命令:netstat -ano|findstr "5037"
TCP 127.0.0.1:1110 127.0.0.1:5037 TIME_WAIT 0
TCP 127.0.0.1:1136 127.0.0.1:5037 CLOSE_WAIT 7600(kill)
TCP 127.0.0.1:5037 0.0.0.0:0 LISTENING 4060(ADB)
TCP 127.0.0.1:5037 127.0.0.1:1096 TIME_WAIT 0
TCP 127.0.0.1:5037 127.0.0.1:1110 TIME_WAIT 0
TCP 127.0.0.1:5037 127.0.0.1:1136 FIN_WAIT_2 9188(kill)
TCP 127.0.0.1:5037 127.0.0.1:1151 TIME_WAIT 0
杀死占用5037的进程7600和9188。cmd命令:tasklist |findstr "7600"
再查一下:
C:\Users\Administrator>netstat -ano|findstr "5037"
TCP 127.0.0.1:5037 0.0.0.0:0 LISTENING 4060
C:\Users\Administrator>adb devices
List of devices attached
emulator-5556 device