Flutter 環(huán)境配置

安裝 Flutter(國內(nèi)鏡像加速)
1?? 下載 Flutter SDK(清華鏡像)

git clone https://mirrors.tuna.tsinghua.edu.cn/git/flutter-sdk.git -b stable ~/development/flutter

2?? 配置環(huán)境變量

echo 'export PATH="$PATH:$HOME/development/flutter/bin"' >> ~/.zshrc
echo 'export PUB_HOSTED_URL=https://mirrors.tuna.tsinghua.edu.cn/dart-pub/' >> ~/.zshrc
echo 'export FLUTTER_STORAGE_BASE_URL=https://mirrors.tuna.tsinghua.edu.cn/flutter' >> ~/.zshrc
source ~/.zshrc

# 1. 克隆 flutter (stable)
git clone https://github.com/flutter/flutter.git -b stable ~/.flutter

# 2. 添加 PATH
echo 'export PATH="$PATH:$HOME/.flutter/bin"' >> ~/.zshrc
source ~/.zshrc

# 3. 驗(yàn)證
flutter doctor

3?? 驗(yàn)證安裝是否成功

flutter doctor

如果一切正常,你會(huì)看到:

Flutter 3.x.x ? channel stable ? https://mirrors.tuna.tsinghua.edu.cn/git/flutter-sdk.git
問題:1
[?] 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.dev/to/macos-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.

你的 Flutter 已經(jīng)裝好 ?,只是現(xiàn)在還缺 Android SDK(也就是 Android 工具鏈)。
這是 Flutter 在 macOS 上開發(fā) Android 應(yīng)用的必需部分。

第一次打開 Android Studio 時(shí)

啟動(dòng) Android Studio → 會(huì)提示安裝幾個(gè)組件,請(qǐng)務(wù)必勾選:
    ?   ? Android SDK
    ?   ? Android SDK Platform
    ?   ? Android Virtual Device (AVD)
    ?   ? Android SDK Command-line Tools

然后點(diǎn)擊「Next」→「Finish」,等待下載完成。

問題:2

Error: It seems there is already an App at '/Applications/Android Studio.app'.

解決方法
進(jìn)入菜單欄:
Android Studio → Settings(或 Preferences) → Appearance & Behavior → System Settings → Android SDK

image.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容