Unable to locate android SDK for flutter doctor

I have tried uninstalling and reinstalling flutter on my computer twice but whenever I run flutter doctor in the terminal I am still met with the following error.

[✗] 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/docs/get-started/install/macos#android-setup
  for detailed instructions).
  If the Android SDK has been installed to a custom location, set
  ANDROID_SDK_ROOT to that location.
  You may also want to add it to your PATH environment variable.

Does anyone know how to fix this problem? Also, could this be the reason that none of my emulators are running my app? Thanks, and sorry, I am still new to Flutter and android studio.


Solution 1:

If it is unable to locate your Android SDK, the reason might be that your Android SDK path is not up to date.

I think your issue is similar to this: https://github.com/flutter/flutter/issues/45007.

Try flutter config --android-sdk <path-to-your-android-sdk-path> to update the Android SDK path.

Solution 2:

This issue is related to environment variables.

After entering the environment variables, you have to click on the system variables and find the "Path" variable.

Double click on the "Path" variable and add a new one on the right.

There are two directories you need to add, "D: \ AndroidSDK \ platforms" and "D: \ AndroidSDK \ platform-tools".

These two directories can be in different places, remember this.