Recently, I was learning Flutter, and encountered some problems when building the environment, and recorded them.
My computer is a MAC M1 chip
Specific installation reference: Build a Flutter development environment on macOS,
only record the problems encountered here
.bash_profile operation under Mac
-
open terminal
-
Open and edit the profile file
open -e .bash_profile
-
Need to save after adding
source .bash_profile
report error
1. Android sdkmanager not found. Update to the latest Android SDK and ensure that the cmdline-tools are
-
Open sdkManager and select SDK Tools
-
Select Android SDK Command-line Tools(latest) Download
- HTTP Host Availability
✗ HTTP host https://maven.google.com/ is not reachable. Reason: An error
occurred while checking the HTTP host: Operation timed out
-
Solution
-
Search for the http_host_validator.dart file, find it and open it.
My files are located at
/Users/xxxx/Documents/Flutter/flutter/packages/flutter_tools/lib/src
-
Modify it
https://maven.google.com/
to the domestic image of google maven, such ashttps://maven.aliyun.com/repository/google/
-
Delete
/path-to-flutter-sdk/bin/cache
the folder, I can't find this folder , but you can go to the flutter\bin directoryflutter_tools.snapshot
and delete the files in the cache directory -
Re-run
flutter doctor
-
-
zsh: command not found: flutter
After the flutter development environment is configured, exit the terminal, enter the terminal again, and enter the flutter doctor command,
zsh: command not found: flutter
an error will be displayed.The reason is that starting with macOS Catalina, your Mac will use zsh as the default login and interactive shell. You can also set zsh as the default shell in earlier versions of macOS.
-
Solution
-
Open the .zshrc file
open ~/.zshrc
-
If the prompt file does not exist, execute: vim ~/.zshrc to create a new file and open it.
vim ~/.zshrc
-
Then execute open ~/.bash_profile, copy the content in bash_profile to zshrc file, save
open ~/.bash_profile
-
Execute source ~/.zshrc to make the configuration take effect
My configuration is as follows:
export PATH=${ PATH}:"/Users/xxx/Library/Android/sdk/platform-tools" export ANDROID_HOME=/Users/xxx/Library/Android/sdk export PATH=$PATH:$ANDROID_HOME/platform-tools export PATH=/Users/xxx/Documents/Flutter/flutter/bin:$PATH export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
-
-
-
Android license status unknown
Prompt that the certificate is not installed. To install the certificate just execute the following command in the terminal
flutter doctor --android-licenses
Then you will be prompted to choose Y/N, don't hesitate to choose Y all the time, and the certificate can be installed.