Problems with Flutter development environment configuration

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

  1. open terminal

  2. Open and edit the profile file

    open -e .bash_profile  
    
    
  3. 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
    Please add a picture description

  1. 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

    1. 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
      
    2. Modify it https://maven.google.com/to the domestic image of google maven, such ashttps://maven.aliyun.com/repository/google/

    3. Delete /path-to-flutter-sdk/bin/cachethe 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

    4. Re-runflutter doctor

  1. 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: flutteran 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

      1. Open the .zshrc file

        open ~/.zshrc 
        
      2. If the prompt file does not exist, execute: vim ~/.zshrc to create a new file and open it.

        vim ~/.zshrc 
        
      3. Then execute open ~/.bash_profile, copy the content in bash_profile to zshrc file, save

        open ~/.bash_profile
        
      4. 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
      
  2. 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.

Guess you like

Origin blog.csdn.net/MrLizuo/article/details/124398222