准备的软件:
最新版的 Android Studio
安装文件夹下的 jre
文件夹是自带的 OpenJDK 11.0.10
, 我从另外一台安装有 Android Studio
的电脑上复制了这个文件夹并改名为 openJDK
备用
说明:理论上搭建 Flutter
开发环境只要有 Android SDK
就可以了, 可以不安装 Android Studio
。 于是找了个旧电脑来试了一下。当然了, 在开发完整功能的 Flutter
应用程序时, 如果需要编写涉及 Android
的混合代码, 还是配合使用 Android Studio
更方便。
配置 Flutter SDK 使用国内镜像 由于某些不可描述的原因,Flutter SDK
的资源网站访问受到影响,可以通过设置 PUB_HOSTED_URL
和 FLUTTER_STORAGE_BASE_URL
两个环境变量设置为使用国内镜像, 以下两个站点二选一:
使用清华大学镜像: 使用管理员权限打开 CMD窗口
或 PowerShell窗口
,执行以下命令:
1 2 setx "PUB_HOSTED_URL" "https://mirrors.tuna.tsinghua.edu.cn/dart-pub" setx "FLUTTER_STORAGE_BASE_URL" "https://mirrors.tuna.tsinghua.edu.cn/flutter"
使用Flutter官方为中国开发者搭建了临时镜像: 使用管理员权限打开 CMD窗口
或 PowerShell窗口
,执行以下命令:
1 2 setx "PUB_HOSTED_URL" "https://pub.flutter-io.cn" setx "FLUTTER_STORAGE_BASE_URL" "https://storage.flutter-io.cn"
配置 Flutter SDK
打开文件夹 D:\AppData
(没有则新建一个, 或指定其他合适的文件夹)
将下载好的 Flutter SDK
压缩文件复制到该文件夹中,使用 解压到当前位置
解压文件, Flutter SDK
的路径为:D:\AppData\flutter
修改环境变量 path
, 添加一个值: D:\AppData\flutter\bin
(如果使用命令方式修改环境变量,与下一步的 配置JDK
一起修改)
配置 JDK
打开 D:\AppData
文件夹
将 openJDK
复制该文件中, JDK
的路径为:D:\AppData\openJDK
添加环境变量 JAVA_HOME
: 使用 管理员权限
打开 CMD窗口
或 PowerShell窗口
,执行以下命令:
1 setx "JAVA_HOME" "D:\AppData\openJDK" /m
修改环境变量 path
, 添加两个值:%JAVA_HOME%\bin
和 %JAVA_HOME%\jre\bin
, 使用管理员权限打开 CMD窗口
或 PowerShell窗口
,执行以下命令:
1 setx PATH "%PATH%;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;D:\AppData\flutter\bin" /m
将下载好的 commandlinetools-win-8092744_latest.zip
(当前最新版) 文件解压缩, 修改
解压后的文件夹名称
及相关路径
为以下格式: D:\AppData\Android\Sdk\cmdline-tools\latest
, 确保 latest
文件夹内为 bin
、lib
文件夹, 如下图所示:
特别提醒: 文件夹路径不对, 会导致后续步骤不能正确执行, D:\AppData\Android\Sdk\
为 Android SDK
路径, 可根据自己的需要进行修改调整; cmdline-tools\latest
为Android SDK
内部文件夹结构, 不能变动。
添加ANDROID_HOME
环境变量
将 Android SDK
的路径添加到环境变量中, 使用 管理员权限
运行 CMD窗口
或 PowerShell窗口
, 执行以下命令:
1 setx "ANDROID_HOME" "D:\AppData\Android\Sdk" /m
将 D:\AppData\Android\Sdk
替换为自己电脑实际的 Android SDK
路径
在 D:\AppData\Android\Sdk\cmdline-tools\latest\bin
文件夹打开 Powershell
或 CMD
窗口
查看 已安装的包
和 有效的包
, 命令格式: sdkmanager.bat --list
, Powershell窗口
执行情况如下所示:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 PS D:\AppData\Android\Sdk\cmdline-tools\latest\bin> .\sdkmanager.bat --list [=======================================] 100% Computing updates... Available Packages: Path | Version | Description ------- | ------- | ------- add-ons;addon-google_apis-google-15 | 3 | Google APIs add-ons;addon-google_apis-google-16 | 4 | Google APIs add-ons;addon-google_apis-google-17 | 4 | Google APIs add-ons;addon-google_apis-google-18 | 4 | Google APIs add-ons;addon-google_apis-google-19 | 20 | Google APIs add-ons;addon-google_apis-google-21 | 1 | Google APIs add-ons;addon-google_apis-google-22 | 1 | Google APIs add-ons;addon-google_apis-google-23 | 1 | Google APIs add-ons;addon-google_apis-google-24 | 1 | Google APIs build-tools;19.1.0 | 19.1.0 | Android SDK Build-Tools 19.1 build-tools;20.0.0 | 20.0.0 | Android SDK Build-Tools 20 build-tools;21.1.2 | 21.1.2 | Android SDK Build-Tools 21.1.2 build-tools;22.0.1 | 22.0.1 | Android SDK Build-Tools 22.0.1 build-tools;23.0.1 | 23.0.1 | Android SDK Build-Tools 23.0.1 build-tools;23.0.2 | 23.0.2 | Android SDK Build-Tools 23.0.2 build-tools;23.0.3 | 23.0.3 | Android SDK Build-Tools 23.0.3 build-tools;24.0.0 | 24.0.0 | Android SDK Build-Tools 24 build-tools;24.0.1 | 24.0.1 | Android SDK Build-Tools 24.0.1 build-tools;24.0.2 | 24.0.2 | Android SDK Build-Tools 24.0.2 build-tools;24.0.3 | 24.0.3 | Android SDK Build-Tools 24.0.3 build-tools;25.0.0 | 25.0.0 | Android SDK Build-Tools 25 build-tools;25.0.1 | 25.0.1 | Android SDK Build-Tools 25.0.1 build-tools;25.0.2 | 25.0.2 | Android SDK Build-Tools 25.0.2 build-tools;25.0.3 | 25.0.3 | Android SDK Build-Tools 25.0.3 build-tools;26.0.0 | 26.0.0 | Android SDK Build-Tools 26 build-tools;26.0.1 | 26.0.1 | Android SDK Build-Tools 26.0.1 build-tools;26.0.2 | 26.0.2 | Android SDK Build-Tools 26.0.2 build-tools;26.0.3 | 26.0.3 | Android SDK Build-Tools 26.0.3 build-tools;27.0.0 | 27.0.0 | Android SDK Build-Tools 27 build-tools;27.0.1 | 27.0.1 | Android SDK Build-Tools 27.0.1 build-tools;27.0.2 | 27.0.2 | Android SDK Build-Tools 27.0.2 build-tools;27.0.3 | 27.0.3 | Android SDK Build-Tools 27.0.3 build-tools;28.0.0 | 28.0.0 | Android SDK Build-Tools 28 build-tools;28.0.1 | 28.0.1 | Android SDK Build-Tools 28.0.1 build-tools;28.0.2 | 28.0.2 | Android SDK Build-Tools 28.0.2 build-tools;28.0.3 | 28.0.3 | Android SDK Build-Tools 28.0.3 build-tools;29.0.0 | 29.0.0 | Android SDK Build-Tools 29 build-tools;29.0.1 | 29.0.1 | Android SDK Build-Tools 29.0.1 build-tools;29.0.2 | 29.0.2 | Android SDK Build-Tools 29.0.2 build-tools;29.0.3 | 29.0.3 | Android SDK Build-Tools 29.0.3 build-tools;30.0.0 | 30.0.0 | Android SDK Build-Tools 30 build-tools;30.0.1 | 30.0.1 | Android SDK Build-Tools 30.0.1 build-tools;30.0.2 | 30.0.2 | Android SDK Build-Tools 30.0.2 build-tools;30.0.3 | 30.0.3 | Android SDK Build-Tools 30.0.3 build-tools;31.0.0 | 31.0.0 | Android SDK Build-Tools 31 build-tools;32.0.0 | 32.0.0 | Android SDK Build-Tools 32 build-tools;32.1.0-rc1 | 32.1.0 rc1 | Android SDK Build-Tools 32.1-rc1 build-tools;33.0.0-rc2 | 33.0.0 rc2 | Android SDK Build-Tools 33-rc2 cmake;3.10.2.4988404 | 3.10.2 | CMake 3.10.2.4988404 cmake;3.18.1 | 3.18.1 | CMake 3.18.1 cmake;3.6.4111459 | 3.6.4111459 | CMake 3.6.4111459 cmdline-tools;1.0 | 1.0 | Android SDK Command-line Tools cmdline-tools;2.1 | 2.1 | Android SDK Command-line Tools cmdline-tools;3.0 | 3.0 | Android SDK Command-line Tools cmdline-tools;4.0 | 4.0 | Android SDK Command-line Tools cmdline-tools;5.0 | 5.0 | Android SDK Command-line Tools cmdline-tools;6.0 | 6.0 | Android SDK Command-line Tools cmdline-tools;latest | 6.0 | Android SDK Command-line Tools (latest) emulator | 31.2.8 | Android Emulator extras;android;m2repository | 47.0.0 | Android Support Repository extras;google;Android_Emulator_Hypervisor_Driver | 1.8.0 | Android Emulator Hypervisor Driver for AMD Processors (installer) extras;google;auto | 1.1 | Android Auto Desktop Head Unit Emulator extras;google;google_play_services | 49 | Google Play services extras;google;instantapps | 1.9.0 | Google Play Instant Development SDK extras;google;m2repository | 58 | Google Repository extras;google;market_apk_expansion | 1 | Google Play APK Expansion library extras;google;market_licensing | 1 | Google Play Licensing Library extras;google;simulators | 1 | Android Auto API Simulators extras;google;usb_driver | 13 | Google USB Driver extras;google;webdriver | 2 | Google Web Driver extras;intel;Hardware_Accelerated_Execution_Manager | 7.6.5 | Intel x86 Emulator Accelerator (HAXM installer) extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.0 | 1 | Solver for ConstraintLayout 1.0.0 extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-alpha4 | 1 | com.android.support.constraint:constraint-layout-solver:1.0.0-alpha4 extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-alpha8 | 1 | Solver for ConstraintLayout 1.0.0-alpha8 extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-beta1 | 1 | Solver for ConstraintLayout 1.0.0-beta1 extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-beta2 | 1 | Solver for ConstraintLayout 1.0.0-beta2 extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-beta3 | 1 | Solver for ConstraintLayout 1.0.0-beta3 extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-beta4 | 1 | Solver for ConstraintLayout 1.0.0-beta4 extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-beta5 | 1 | Solver for ConstraintLayout 1.0.0-beta5 extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.1 | 1 | Solver for ConstraintLayout 1.0.1 extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2 | 1 | Solver for ConstraintLayout 1.0.2 extras;m2repository;com;android;support;constraint;constraint-layout;1.0.0 | 1 | ConstraintLayout for Android 1.0.0 extras;m2repository;com;android;support;constraint;constraint-layout;1.0.0-alpha4 | 1 | com.android.support.constraint:constraint-layout:1.0.0-alpha4 extras;m2repository;com;android;support;constraint;constraint-layout;1.0.0-alpha8 | 1 | ConstraintLayout for Android 1.0.0-alpha8 extras;m2repository;com;android;support;constraint;constraint-layout;1.0.0-beta1 | 1 | ConstraintLayout for Android 1.0.0-beta1 extras;m2repository;com;android;support;constraint;constraint-layout;1.0.0-beta2 | 1 | ConstraintLayout for Android 1.0.0-beta2 extras;m2repository;com;android;support;constraint;constraint-layout;1.0.0-beta3 | 1 | ConstraintLayout for Android 1.0.0-beta3 extras;m2repository;com;android;support;constraint;constraint-layout;1.0.0-beta4 | 1 | ConstraintLayout for Android 1.0.0-beta4 extras;m2repository;com;android;support;constraint;constraint-layout;1.0.0-beta5 | 1 | ConstraintLayout for Android 1.0.0-beta5 extras;m2repository;com;android;support;constraint;constraint-layout;1.0.1 | 1 | ConstraintLayout for Android 1.0.1 extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2 | 1 | ConstraintLayout for Android 1.0.2 ndk-bundle | 22.1.7171670 | NDK ndk;16.1.4479499 | 16.1.4479499 | NDK (Side by side) 16.1.4479499 ndk;17.2.4988734 | 17.2.4988734 | NDK (Side by side) 17.2.4988734 ndk;18.1.5063045 | 18.1.5063045 | NDK (Side by side) 18.1.5063045 ndk;19.2.5345600 | 19.2.5345600 | NDK (Side by side) 19.2.5345600 ndk;20.0.5594570 | 20.0.5594570 | NDK (Side by side) 20.0.5594570 ndk;20.1.5948944 | 20.1.5948944 | NDK (Side by side) 20.1.5948944 ndk;21.0.6113669 | 21.0.6113669 | NDK (Side by side) 21.0.6113669 ndk;21.1.6352462 | 21.1.6352462 | NDK (Side by side) 21.1.6352462 ndk;21.2.6472646 | 21.2.6472646 | NDK (Side by side) 21.2.6472646 ndk;21.3.6528147 | 21.3.6528147 | NDK (Side by side) 21.3.6528147 ndk;21.4.7075529 | 21.4.7075529 | NDK (Side by side) 21.4.7075529 ndk;22.0.7026061 | 22.0.7026061 | NDK (Side by side) 22.0.7026061 ndk;22.1.7171670 | 22.1.7171670 | NDK (Side by side) 22.1.7171670 ndk;23.0.7599858 | 23.0.7599858 | NDK (Side by side) 23.0.7599858 ndk;23.1.7779620 | 23.1.7779620 | NDK (Side by side) 23.1.7779620 ndk;24.0.8215888 | 24.0.8215888 | NDK (Side by side) 24.0.8215888 patcher;v4 | 1 | SDK Patch Applier v4 platform-tools | 33.0.1 | Android SDK Platform-Tools platforms;android-10 | 2 | Android SDK Platform 10 platforms;android-11 | 2 | Android SDK Platform 11 platforms;android-12 | 3 | Android SDK Platform 12 platforms;android-13 | 1 | Android SDK Platform 13 platforms;android-14 | 4 | Android SDK Platform 14 platforms;android-15 | 5 | Android SDK Platform 15 platforms;android-16 | 5 | Android SDK Platform 16 platforms;android-17 | 3 | Android SDK Platform 17 platforms;android-18 | 3 | Android SDK Platform 18 platforms;android-19 | 4 | Android SDK Platform 19 platforms;android-20 | 2 | Android SDK Platform 20 platforms;android-21 | 2 | Android SDK Platform 21 platforms;android-22 | 2 | Android SDK Platform 22 platforms;android-23 | 3 | Android SDK Platform 23 platforms;android-24 | 2 | Android SDK Platform 24 platforms;android-25 | 3 | Android SDK Platform 25 platforms;android-26 | 2 | Android SDK Platform 26 platforms;android-27 | 3 | Android SDK Platform 27 platforms;android-28 | 6 | Android SDK Platform 28 platforms;android-29 | 5 | Android SDK Platform 29 platforms;android-30 | 3 | Android SDK Platform 30 platforms;android-31 | 1 | Android SDK Platform 31 platforms;android-32 | 1 | Android SDK Platform 32 platforms;android-7 | 3 | Android SDK Platform 7 platforms;android-8 | 3 | Android SDK Platform 8 platforms;android-9 | 2 | Android SDK Platform 9 platforms;android-Tiramisu | 2 | Android SDK Platform Tiramisu skiaparser;1 | 6 | Layout Inspector image server for API 29-30 skiaparser;2 | 3 | Layout Inspector image server for API S sources;android-15 | 2 | Sources for Android 15 sources;android-16 | 2 | Sources for Android 16 sources;android-17 | 1 | Sources for Android 17 sources;android-18 | 1 | Sources for Android 18 sources;android-19 | 2 | Sources for Android 19 sources;android-20 | 1 | Sources for Android 20 sources;android-21 | 1 | Sources for Android 21 sources;android-22 | 1 | Sources for Android 22 sources;android-23 | 1 | Sources for Android 23 sources;android-24 | 1 | Sources for Android 24 sources;android-25 | 1 | Sources for Android 25 sources;android-26 | 1 | Sources for Android 26 sources;android-27 | 1 | Sources for Android 27 sources;android-28 | 1 | Sources for Android 28 sources;android-29 | 1 | Sources for Android 29 sources;android-30 | 1 | Sources for Android 30 sources;android-31 | 1 | Sources for Android 31 system-images;android-10;default;armeabi-v7a | 5 | ARM EABI v7a System Image system-images;android-10;default;x86 | 5 | Intel x86 Atom System Image system-images;android-10;google_apis;armeabi-v7a | 6 | Google APIs ARM EABI v7a System Image system-images;android-10;google_apis;x86 | 6 | Google APIs Intel x86 Atom System Image system-images;android-14;default;armeabi-v7a | 2 | ARM EABI v7a System Image system-images;android-15;default;armeabi-v7a | 5 | ARM EABI v7a System Image system-images;android-15;default;x86 | 7 | Intel x86 Atom System Image system-images;android-15;google_apis;armeabi-v7a | 6 | Google APIs ARM EABI v7a System Image system-images;android-15;google_apis;x86 | 7 | Google APIs Intel x86 Atom System Image system-images;android-16;default;armeabi-v7a | 6 | ARM EABI v7a System Image system-images;android-16;default;mips | 1 | MIPS System Image system-images;android-16;default;x86 | 7 | Intel x86 Atom System Image system-images;android-16;google_apis;armeabi-v7a | 6 | Google APIs ARM EABI v7a System Image system-images;android-16;google_apis;x86 | 7 | Google APIs Intel x86 Atom System Image system-images;android-17;default;armeabi-v7a | 6 | ARM EABI v7a System Image system-images;android-17;default;mips | 1 | MIPS System Image system-images;android-17;default;x86 | 7 | Intel x86 Atom System Image system-images;android-17;google_apis;armeabi-v7a | 6 | Google APIs ARM EABI v7a System Image system-images;android-17;google_apis;x86 | 7 | Google APIs Intel x86 Atom System Image system-images;android-18;default;armeabi-v7a | 5 | ARM EABI v7a System Image system-images;android-18;default;x86 | 4 | Intel x86 Atom System Image system-images;android-18;google_apis;armeabi-v7a | 6 | Google APIs ARM EABI v7a System Image system-images;android-18;google_apis;x86 | 6 | Google APIs Intel x86 Atom System Image system-images;android-19;default;armeabi-v7a | 5 | ARM EABI v7a System Image system-images;android-19;default;x86 | 6 | Intel x86 Atom System Image system-images;android-19;google_apis;armeabi-v7a | 40 | Google APIs ARM EABI v7a System Image system-images;android-19;google_apis;x86 | 40 | Google APIs Intel x86 Atom System Image system-images;android-21;android-tv;armeabi-v7a | 3 | Android TV ARM EABI v7a System Image system-images;android-21;android-tv;x86 | 3 | Android TV Intel x86 Atom System Image system-images;android-21;default;armeabi-v7a | 4 | ARM EABI v7a System Image system-images;android-21;default;x86 | 5 | Intel x86 Atom System Image system-images;android-21;default;x86_64 | 5 | Intel x86 Atom_64 System Image system-images;android-21;google_apis;armeabi-v7a | 32 | Google APIs ARM EABI v7a System Image system-images;android-21;google_apis;x86 | 32 | Google APIs Intel x86 Atom System Image system-images;android-21;google_apis;x86_64 | 32 | Google APIs Intel x86 Atom_64 System Image system-images;android-22;android-tv;x86 | 3 | Android TV Intel x86 Atom System Image system-images;android-22;default;armeabi-v7a | 2 | ARM EABI v7a System Image system-images;android-22;default;x86 | 6 | Intel x86 Atom System Image system-images;android-22;default;x86_64 | 6 | Intel x86 Atom_64 System Image system-images;android-22;google_apis;armeabi-v7a | 26 | Google APIs ARM EABI v7a System Image system-images;android-22;google_apis;x86 | 26 | Google APIs Intel x86 Atom System Image system-images;android-22;google_apis;x86_64 | 26 | Google APIs Intel x86 Atom_64 System Image system-images;android-23;android-tv;armeabi-v7a | 12 | Android TV ARM EABI v7a System Image system-images;android-23;android-tv;x86 | 21 | Android TV Intel x86 Atom System Image system-images;android-23;default;armeabi-v7a | 6 | ARM EABI v7a System Image system-images;android-23;default;x86 | 10 | Intel x86 Atom System Image system-images;android-23;default;x86_64 | 10 | Intel x86 Atom_64 System Image system-images;android-23;google_apis;armeabi-v7a | 33 | Google APIs ARM EABI v7a System Image system-images;android-23;google_apis;x86 | 33 | Google APIs Intel x86 Atom System Image system-images;android-23;google_apis;x86_64 | 33 | Google APIs Intel x86 Atom_64 System Image system-images;android-24;android-tv;x86 | 22 | Android TV Intel x86 Atom System Image system-images;android-24;default;arm64-v8a | 7 | ARM 64 v8a System Image system-images;android-24;default;armeabi-v7a | 7 | ARM EABI v7a System Image system-images;android-24;default;x86 | 8 | Intel x86 Atom System Image system-images;android-24;default;x86_64 | 8 | Intel x86 Atom_64 System Image system-images;android-24;google_apis;arm64-v8a | 27 | Google APIs ARM 64 v8a System Image system-images;android-24;google_apis;x86 | 27 | Google APIs Intel x86 Atom System Image system-images;android-24;google_apis;x86_64 | 27 | Google APIs Intel x86 Atom_64 System Image system-images;android-24;google_apis_playstore;x86 | 19 | Google Play Intel x86 Atom System Image system-images;android-25;android-tv;x86 | 16 | Android TV Intel x86 Atom System Image system-images;android-25;android-wear-cn;armeabi-v7a | 4 | China version of Android Wear ARM EABI v7a System Image system-images;android-25;android-wear-cn;x86 | 4 | China version of Android Wear Intel x86 Atom System Image system-images;android-25;android-wear;armeabi-v7a | 3 | Android Wear ARM EABI v7a System Image system-images;android-25;android-wear;x86 | 3 | Android Wear Intel x86 Atom System Image system-images;android-25;default;x86 | 1 | Intel x86 Atom System Image system-images;android-25;default;x86_64 | 1 | Intel x86 Atom_64 System Image system-images;android-25;google_apis;arm64-v8a | 18 | Google APIs ARM 64 v8a System Image system-images;android-25;google_apis;armeabi-v7a | 18 | Google APIs ARM EABI v7a System Image system-images;android-25;google_apis;x86 | 18 | Google APIs Intel x86 Atom System Image system-images;android-25;google_apis;x86_64 | 18 | Google APIs Intel x86 Atom_64 System Image system-images;android-25;google_apis_playstore;x86 | 9 | Google Play Intel x86 Atom System Image system-images;android-26;android-tv;x86 | 14 | Android TV Intel x86 Atom System Image system-images;android-26;android-wear-cn;x86 | 4 | China version of Android Wear Intel x86 Atom System Image system-images;android-26;android-wear;x86 | 4 | Android Wear Intel x86 Atom System Image system-images;android-26;default;x86 | 1 | Intel x86 Atom System Image system-images;android-26;default;x86_64 | 1 | Intel x86 Atom_64 System Image system-images;android-26;google_apis;x86 | 16 | Google APIs Intel x86 Atom System Image system-images;android-26;google_apis;x86_64 | 16 | Google APIs Intel x86 Atom_64 System Image system-images;android-26;google_apis_playstore;x86 | 7 | Google Play Intel x86 Atom System Image system-images;android-27;android-tv;x86 | 9 | Android TV Intel x86 Atom System Image system-images;android-27;default;x86 | 1 | Intel x86 Atom System Image system-images;android-27;default;x86_64 | 1 | Intel x86 Atom_64 System Image system-images;android-27;google_apis;x86 | 11 | Google APIs Intel x86 Atom System Image system-images;android-27;google_apis_playstore;x86 | 3 | Google Play Intel x86 Atom System Image system-images;android-28;android-tv;x86 | 10 | Android TV Intel x86 Atom System Image system-images;android-28;android-wear-cn;x86 | 9 | China version of Wear OS Intel x86 Atom System Image system-images;android-28;android-wear;x86 | 9 | Wear OS Intel x86 Atom System Image system-images;android-28;default;arm64-v8a | 1 | ARM 64 v8a System Image system-images;android-28;default;x86 | 4 | Intel x86 Atom System Image system-images;android-28;default;x86_64 | 4 | Intel x86 Atom_64 System Image system-images;android-28;google_apis;arm64-v8a | 1 | Google APIs ARM 64 v8a System Image system-images;android-28;google_apis;x86 | 12 | Google APIs Intel x86 Atom System Image system-images;android-28;google_apis;x86_64 | 11 | Google APIs Intel x86 Atom_64 System Image system-images;android-28;google_apis_playstore;arm64-v8a | 1 | Google ARM64-V8a Play ARM 64 v8a System Image system-images;android-28;google_apis_playstore;x86 | 9 | Google Play Intel x86 Atom System Image system-images;android-28;google_apis_playstore;x86_64 | 8 | Google Play Intel x86 Atom_64 System Image system-images;android-29;android-tv;x86 | 3 | Android TV Intel x86 Atom System Image system-images;android-29;default;arm64-v8a | 8 | ARM 64 v8a System Image system-images;android-29;default;x86 | 8 | Intel x86 Atom System Image system-images;android-29;default;x86_64 | 8 | Intel x86 Atom_64 System Image system-images;android-29;google_apis;arm64-v8a | 12 | Google APIs ARM 64 v8a System Image system-images;android-29;google_apis;x86 | 12 | Google APIs Intel x86 Atom System Image system-images;android-29;google_apis;x86_64 | 12 | Google APIs Intel x86 Atom_64 System Image system-images;android-29;google_apis_playstore;x86 | 8 | Google Play Intel x86 Atom System Image system-images;android-29;google_apis_playstore;x86_64 | 8 | Google Play Intel x86 Atom_64 System Image system-images;android-30;android-tv;x86 | 3 | Android TV Intel x86 Atom System Image system-images;android-30;android-wear-cn;x86 | 10 | China version of Wear OS 3 - Preview Intel x86 Atom System Image system-images;android-30;android-wear;arm64-v8a | 10 | Wear OS 3 - Preview ARM 64 v8a System Image system-images;android-30;android-wear;x86 | 10 | Wear OS 3 - Preview Intel x86 Atom System Image system-images;android-30;default;arm64-v8a | 1 | ARM 64 v8a System Image system-images;android-30;default;x86_64 | 10 | Intel x86 Atom_64 System Image system-images;android-30;google-tv;x86 | 3 | Google TV Intel x86 Atom System Image system-images;android-30;google_apis;arm64-v8a | 11 | Google APIs ARM 64 v8a System Image system-images;android-30;google_apis;x86 | 10 | Google APIs Intel x86 Atom System Image system-images;android-30;google_apis;x86_64 | 11 | Google APIs Intel x86 Atom_64 System Image system-images;android-30;google_apis_playstore;x86 | 9 | Google Play Intel x86 Atom System Image system-images;android-30;google_apis_playstore;x86_64 | 10 | Google Play Intel x86 Atom_64 System Image system-images;android-31;android-tv;x86 | 3 | Android TV Intel x86 Atom System Image system-images;android-31;default;arm64-v8a | 3 | ARM 64 v8a System Image system-images;android-31;default;x86_64 | 3 | Intel x86 Atom_64 System Image system-images;android-31;google-tv;x86 | 3 | Google TV Intel x86 Atom System Image system-images;android-31;google_apis;arm64-v8a | 9 | Google APIs ARM 64 v8a System Image system-images;android-31;google_apis;x86_64 | 9 | Google APIs Intel x86 Atom_64 System Image system-images;android-31;google_apis_playstore;x86_64 | 9 | Google Play Intel x86 Atom_64 System Image system-images;android-32;google_apis;arm64-v8a | 3 | Google APIs ARM 64 v8a System Image system-images;android-32;google_apis;x86_64 | 3 | Google APIs Intel x86 Atom_64 System Image system-images;android-32;google_apis_playstore;x86_64 | 3 | Google Play Intel x86 Atom_64 System Image system-images;android-Tiramisu;google_apis;arm64-v8a | 2 | Google APIs ARM 64 v8a System Image system-images;android-Tiramisu;google_apis;x86_64 | 2 | Google APIs Intel x86 Atom_64 System Image system-images;android-Tiramisu;google_apis_playstore;x86_64 | 2 | Google Play Intel x86 Atom_64 System Image
安装 Android SDK
软件包
安装命令: sdkmanager <packages>
这里至少需要安装三个组件: platform-tools
、 build-tools
、 platforms
命令:./sdkmanager "platform-tools" "build-tools;30.0.3" "platforms;android-34"
说明: 不同版本的 Flutter SDK
要求的这三个组件的版本会有所不同, 如果不知道具体的版本需求, 可以按以上版本进行安装, 等项目运行时, Flutter
会自动下载正确的版本。
Flutter 3.16.x
需要 Android SDK Platform 33
,命令可以更改为: ./sdkmanager "platform-tools" "build-tools;30.0.3" "platforms;android-33"
Powershell窗口
执行情况如下所示:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 PS D:\AppData\Android\Sdk\cmdline-tools\latest\bin> .\sdkmanager.bat "platform-tools" "build-tools;30.0.3" "platforms;android-34" License android-sdk-license: ] 10% Computing updates... --------------------------------------- Terms and Conditions This is the Android Software Development Kit License Agreement 1. Introduction 1.1 The Android Software Development Kit (referred to in the License Agreement as the "SDK" and specifically including the Android system files, packaged APIs, and Google APIs add-ons) is licensed to you subject to the terms of the License Agreement. The License Agreement forms a legally binding contract between you and Google in relation to your use of the SDK. <中间是很长的协议条文, 省略> January 16, 2019 --------------------------------------- Accept? (y/N): y [=======================================] 100% Unzipping... android-11/renderscr
检测 Flutter 环境
执行命令:flutter doctor -v
, 执行效果如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 PS D:\sources\flutter_repos> flutter doctor -v [√] Flutter (Channel stable, 3.7.0, on Microsoft Windows [Version 10.0.17763.316], locale zh-CN) • Flutter version 3.7.0 at C:\Users\Laohoo\AppData\Local\Android\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 7e9793dee1 (2 weeks ago), 2022-03-02 11:23:12 -0600 • Engine revision bd539267b4 • Dart version 2.19 • DevTools version 2.9.2 [!] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at C:\Users\Laohoo\AppData\Local\Android\Sdk • Platform android-33, build-tools 30.0.3 • ANDROID_HOME = C:\Users\Laohoo\AppData\Local\Android\Sdk • Java binary at: C:\Users\Laohoo\AppData\Local\Android\openJDK\bin\java • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822) ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses [X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [X] Visual Studio - develop for Windows X Visual Studio not installed; this is necessary for Windows development. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components [!] Android Studio (not installed) • Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions). [√] VS Code, 64-bit edition (version 1.65.2) • VS Code at C:\Program Files\Microsoft VS Code • Flutter extension version 3.36.0 [√] Connected device (2 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.17763.316] • Edge (web) • edge • web-javascript • Microsoft Edge 99.0.1150.46 [!] HTTP Host Availability X HTTP host https://maven.google.com/ is not reachable. Reason: An error occurred while checking the HTTP host: 信号灯超时时间已到 X HTTP host https://cloud.google.com/ is not reachable. Reason: An error occurred while checking the HTTP host: 信号灯超时时间已到 ! Doctor found issues in 5 categories.
接受 Android 许可证
执行命令:flutter doctor --android-licenses
, 所有问题回答: y
再次检测 flutter 环境
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 PS D:\sources\flutter_repos> flutter doctor -v [√] Flutter (Channel stable, 2.10.3, on Microsoft Windows [Version 10.0.17763.316], locale zh-CN) • Flutter version 2.10.3 at C:\Users\Laohoo\AppData\Local\Android\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 7e9793dee1 (2 weeks ago), 2022-03-02 11:23:12 -0600 • Engine revision bd539267b4 • Dart version 2.16.1 • DevTools version 2.9.2 [√] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at C:\Users\Laohoo\AppData\Local\Android\Sdk • Platform android-30, build-tools 29.0.2 • ANDROID_HOME = C:\Users\Laohoo\AppData\Local\Android\Sdk • Java binary at: C:\Users\Laohoo\AppData\Local\Android\openJDK\bin\java • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822) • All Android licenses accepted. [X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [X] Visual Studio - develop for Windows X Visual Studio not installed; this is necessary for Windows development. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components [!] Android Studio (not installed) • Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions). [√] VS Code, 64-bit edition (version 1.65.2) • VS Code at C:\Program Files\Microsoft VS Code • Flutter extension version 3.36.0 [√] Connected device (2 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.17763.316] • Edge (web) • edge • web-javascript • Microsoft Edge 99.0.1150.46 [☠] HTTP Host Availability (the doctor check crashed) X Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues. X HandshakeException: Connection terminated during handshake • ! Doctor found issues in 4 categories.
Android toolchain
(Android 工具链) 检测正常, 安装完成。
visual Studio Code
安装步骤省略;
雷电模拟器
(不需要特别配置, 推荐)下载地址:https://www.ldmnq.com/
夜神模拟器
安装配置步骤请参考:https://hujiyi.github.io/2021/12/04/flutter-development-environment-configuration/
雷电模拟器
、 夜神模拟器
或是 Android Studio
自带的模拟器, 只需要选择其中任意一个就可以。