安装软件

参考

git

git 代码版本控制

https://git-scm.com/

Android Studio

安装

官网

https://developer.android.com/studio/index.html?hl=zh-cn

选择需要的版本下载,intel apple cpu 区分下

首次安装需要去下载 sdk,一路默认就行,请打开加速,这个 dl.google.com 不太稳

SDK 配置

点击 “SDK Manager”

SDK 列表, 可以先勾选个 Android 12 的,以后根据需要再加

SDK Tools, 安装 command-line、x86 加速器

XCode

安装

Apple Store 中升级到最新的 xcode

如果你原来的 xcode 很大,可以直接删除,装个新的

cocoapods

https://cocoapods.org

$ sudo gem install cocoapods

M1 机器

$ sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc

配置 command-line

多个版本需要配置你的 xcode 主目录,默认不需要操作

$ sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
$ sudo xcodebuild -runFirstLaunch

同意 Xcode license

同意协议,默认不需要操作

$ sudo xcodebuild -license

Flutter SDK

压缩包方式

sdk 压缩包列表

https://docs.flutter.dev/development/tools/sdk/releases?tab=macos

我现在用的 2.10.5 , v3 大家还是再等等

比如你解压到 ~/Documents/sdk/flutter

环境变量

  • macos

打开 .bash_profile 配置文件

$ vi ~/.bash_profile

写入配置

# flutter sdk
export PATH=${PATH}:~/Documents/sdk/flutter/bin

# dart sdk
export PATH=${PATH}:~/Documents/sdk/flutter/bin/cache/dart-sdk/bin
export PATH=${PATH}:~/.pub-cache/bin

# flutter-io 国内镜像
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

# android
export ANDROID_HOME=~/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=${PATH}:${ANDROID_HOME}/tools

生效

$ source ~/.bash_profile

检查

$ flutter doctor

输出

$ flutter doctor
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
Running "flutter pub get" in flutter_tools...                       3.9s
Doctor summary (to see all details, run flutter doctor -v):
[] Flutter (Channel stable, 2.10.5, on macOS 12.3.1 21E258 darwin-x64, locale zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[] Xcode - develop for iOS and macOS (Xcode 13.4)
[] Chrome - develop for the web
[] Android Studio (version 2021.2)
[] VS Code (version 1.67.2)
[!] Proxy Configuration
    ! NO_PROXY does not contain ::1
[] Connected device ()
[] HTTP Host Availability

! Doctor found issues in 2 categories.

同意 Android Licenses

flutter doctor --android-licenses

windows 下设置

邮件 我的电脑 -> 属性

点击 高级系统设置

点击 环境变量

参考 macos 下的属性进行添加修改

常见问题

  • OS Error: Too many open files, errno = 24
$ ulimit -S -n 2048
  • Pub failed to run subprocess chmod: ProcessException: Too many open files, Command: chmod 755 /Users/ducafecat/Documents/sdk/flutter/.pub-cache/_temp/dirCGtulO/test/download-spec.sh
chmod -R 755 /Users/ducafecat/Documents/sdk/flutter/
  • Android sdkmanager not found. Update to the latest Android SDK and ensure that the cmdline-tools are installed to resolve this.

需要你去安装 Android 的 cmdline-tools

Last Updated:
Contributors: ducafecat