Several Flutter common diagnostic errors and solutions Android toolchain - develop for Android devices X Unable to locate Android SDK

Several Flutter common diagnostic errors and solutions

jcLee95https://blog.csdn.net/qq_28550263
https://blog.csdn.net/qq_28550263/article/details/132869987


Flutter diagnostics FAQ

Question 1:

Problem Description

[X] Android toolchain - develop for Android devices
    X 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/docs/get-started/install/windows#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.

Cause Analysis

This error means that the Android SDK cannot be found. The possible reason is that Android Studio is not installed or the installation path is not configured correctly.

Solution

PS > flutter config --android-sdk D:\Android\SDK
Setting "android-sdk" value to "D:\Android\SDK".

You may need to restart any open editors for them to read new settings.

Question 2:

Problem Description

[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.

Causes and solutions

This error message indicates that the Flutter environment lacks the necessary Android toolchain and SDK licenses. Below are solutions for each error.

1. Error message: cmdline-tools component is missing

✗ cmdline-tools component is missing
  Run `path/to/sdkmanager --install "cmdline-tools;latest"`

Solution:

  • Open a terminal and run the above command, path/to/sdkmanagerreplacing the path to your Android SDK. This command will install the latest cmdline-tools component. Example:
    /path/to/android/sdk/tools/bin/sdkmanager --install "cmdline-tools;latest"
    
  • If you don't know the exact path to the Android SDK, you can use flutter configthe command to find it. Run the following command:
    flutter config --android-sdk
    
    For example:
    flutter config --android-sdk D:\Android\android-sdk
    

2. Error message: Android license status unknown

✗ Android license status unknown.
  Run `flutter doctor --android-licenses` to accept the SDK licenses.

Solution:

  • Run the following command to accept the Android SDK's license:
    flutter doctor --android-licenses
    
  • When running this command, you may be asked to confirm or accept a number of licenses, such as:
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
7 of 7 SDK package licenses not accepted. 100% Computing updates...
Review licenses that have not been accepted (y/N)? Y 

Please enter yto accept them and press Enter to confirm.

After completing the above steps, your Flutter environment should be able to run normally and these error messages will no longer be displayed. If you encounter other issues, please check your Flutter and Android SDK installations and make sure they are both configured correctly.

Question 3:

Problem Description

[!] Network resources
    ✗ An HTTP error occurred while checking "https://github.com/": 信号灯超时时间已到

This error message indicates that an HTTP error occurred while trying to check the resource on GitHub, and the error message mentions "Semaphore timeout expired." This is usually caused by network issues or the GitHub server being inaccessible. Here are some possible solutions:

  • Check network connection :

    • Make sure your computer has access to the Internet. Open your browser and try visiting other websites to make sure your connection is working.
    • If you use a proxy server or VPN, make sure they are configured correctly and are not blocking access to GitHub.
  • Try using proxy :

    • If you work in an environment with network restrictions (you need to experience this yourself, major blog platforms do not allow explanations), you may need to configure a proxy server. Set up a proxy server in the terminal so that your Flutter environment can access GitHub. The proxy configuration method depends on your network environment and operating system.
  • Check GitHub status :

    • From time to time, GitHub itself may experience issues or maintenance. You can visit GitHub Status to check the current status of GitHub. If GitHub is under maintenance or encounters an issue, you may need to wait for a while and try again.
  • Change the warehouse source :

    • If you use a custom Flutter image source or package manager source, try switching back to the default source or changing to a reliable source to ensure normal access to GitHub.
  • Check firewall and security software :

    • Some firewalls or security software may block your computer from accessing specific websites or resources. Make sure no security software or firewall rules are blocking access to GitHub.

Guess you like

Origin blog.csdn.net/qq_28550263/article/details/132869987