Configuration of flutter environment variables in Mac OS

Time:2021-2-22

reference resourcesThis article)

//Android SDK environment variable configuration (those not configured need to be configured)
export ANDROID_HOME="/Users/WES319MAC/Library/Android/sdk" 
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
//Open (or create). Bash_ profile
open -e .bash_profile

Add the following code to the file edit and save the file
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=/Users/WES319MAC/Library/flutter/bin:$PATH

be careful:
1. Because some flutter commands need to be connected to the Internet to obtain data, if you are visiting in China, due to well-known reasons, direct access is unlikely to succeed. The upper Pub_ HOSTED_ URL and flutter_ STORAGE_ BASE_ URL is a temporary image built by Google for domestic developers.
2. Wes319mac is the user name of my local machine. Please replace it with your own user name when configuring. Pay attention to confirm the local path of your own flutter SDK.

After the above configuration, execute the following command:

//1. Refresh the current terminal window
source $HOME/.bash_profile
//2. Check whether the configuration of flutter is in the path environment variable
echo $PATH

Run the flutter doctor to display the remaining dependencies you may need to install:

WES319deMac-mini:~ WES319MAC$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.14.3 18D109, locale
    zh-Hans-HK)
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor
      --android-licenses
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2)
[✓] Android Studio (version 3.3)
[✓] Connected device (1 available)

! Doctor found issues in 1 category.

If the above similar results are output and no command not found is prompted, the configuration is successful.