helloworld12345
helloworld12345

Reputation: 127

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.

Upvotes: 8

Views: 24337

Answers (8)

Leezan
Leezan

Reputation: 1

I had two major issues: sdkmanager couldn't be found in terminal and Flutter didnot show Android SDK

So for first issue: I made sdkmanager available. I downloaded unzipped android commandlinetools-linux-11076708_latest.zip in to my defined path

cd ~/Development/Android/Sdk

this is path you'll extract

unzip ~/Downloads/commandlinetools-linux-11076708_latest.zip

made a new folder inside cmdline-tools and moved into it, such that:

~/Development/Android/Sdk/cmdline-tools/tools/ (bin and other content)

now added it to the $PATH

kwrite ~/.bashrc

#add it to .bashrc

export ANDROID_HOME=$HOME/Development/Android/Sdk
export PATH=$ANDROID_HOME/cmdline-tools/tools/bin:$PATH

Doing this made my sdkmanager available in terminal. try:

which sdkmanager

It should give the path.

Now the Second issue: Flutter Didnot show Android SDK for it i ran

flutter config --android-sdk=/home/leezannn/Development/Android/Sdk

and need to install other sdk-packages

sdkmanager "build-tools;34.0.0" "platforms;android-34" "platform-tools" "cmdline-tools;latest"

check and specify the versions yourself with

sdkmanager --list | grep build-tools

Now run flutter doctor --android-licenses and pressed y to everything.

You can See the specific problem by running

flutter doctor -v

Upvotes: 0

For more clarity on how to add the path

Run this for adding to path,

flutter config --android-sdk "path to your sdk root"

Example

flutter config --android-sdk "/Users/clovisokonkwo/androidSdk"

Then this for accepting license

flutter doctor --android-licenses

Upvotes: 0

FedericoCozziVM
FedericoCozziVM

Reputation: 146

In my experience, flutter doctor reported an issue and failed to locate Android sdk (even having specified sdk path with flutter config --android-sdk) also if there is a problem with any platform or build tool installed.

In my case the correct build-tools for my platform was missing and after installing it with sdkmanager also the issue related to sdk path in flutter doctor disappeared.

My working android sdk configuration (based on Android platform 30) is:

  Path                 | Version | Description                    | Location            
  -------              | ------- | -------                        | -------             
  build-tools;30.0.3   | 30.0.3  | Android SDK Build-Tools 30.0.3 | build-tools/30.0.3  
  emulator             | 31.3.11 | Android Emulator               | emulator            
  patcher;v4           | 1       | SDK Patch Applier v4           | patcher/v4          
  platform-tools       | 33.0.3  | Android SDK Platform-Tools     | platform-tools      
  platforms;android-30 | 3       | Android SDK Platform 30        | platforms/android-30

Hope this helps anyone facing the same problem, having set the correct path to android sdk

Upvotes: 0

aCiD
aCiD

Reputation: 1333

For flutter 10.2.3 and Android Studio Bumblebee, I had to uninstall sdk using

File -> Settings > Appearance & Behavior -> system Settings -> Android SDK > SDK Platforms > uncheck all and apply.

After uninstall, I had remove to remaining contents in the Android SDK location manually.

Then install again

File -> Settings > Appearance & Behavior -> system Settings -> Android SDK > SDK Platforms > Check Android API 32 -> apply

Install in SDK Tools tab -> expand Android SDK Build Tools -> 32.0.0 and Android Command Line tools (latest)

Then set

flutter config --android-sdk "path to your sdk root"

Upvotes: 0

Konflex
Konflex

Reputation: 485

If you do for example:

flutter config --android-sdk C:\Users\User\AppData\Local\Android\Sdk

and nothing happen, it is normal you have to double backslash like this:

flutter config --android-sdk C:\\Users\\User\\AppData\\Local\\Android\\Sdk

Upvotes: 2

devsandesh
devsandesh

Reputation: 41

Faced the same issue when I moved my android studio to my external hard drive on my MacBook, here are steps I followed to fix

1 set the andriod sdk path flutter config --android-sdk example: flutter config --android-sdk /Volumes/Apps/Library/Android

Once done it showed another error: Android license status unknown. to fix this we need to add andriod studio directory, that is android studio app. Like this: flutter config --android-studio-dir example: flutter config --android-studio-dir /Volumes/Apps/Android\ Studio.app

finally access the licensed from android studio, using below command and your are done. flutter doctor --android-licenses

Upvotes: 1

atilaykosker
atilaykosker

Reputation: 94

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.

Upvotes: 3

OhJohnny
OhJohnny

Reputation: 351

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.

Upvotes: 15

Related Questions