简体   繁体   中英

Unable to locate the Android SDK

I already had Android Studio and the Android SDK installed. I later added Flutter and the Flutter SDK. Here is my problem: When I run

flutter doctor

It shows,

在此处输入图像描述

that I do not have the Android SDK installed.

You can configure the Android SDK for your project using

flutter config --android-sdk /path/to/android/sdk  

The PATH variable also should contain the SDK like

export PATH=$PATH:/usr/local/opt/android-sdk/emulator:/usr/local/opt/android-sdk/build-tools/26.0.1:/usr/local/opt/android-sdk/platform-tools:/usr/local/opt/android-sdk/tools

/usr/local/opt/android-sdk and 26.0.1 might not match your system, that's just an example.

Locate the android SDK folder.(eg. D:\\SDK)
Add platforms ( D:\\SDK\\platforms ) and platform-tools ( D:\\SDK\\platform-tools ) to the PATH variable.
Run flutter doctor , it should not show any errors or warnings.

Step by Step guidance with picture

Step 1. 在此处输入图片说明

If you see this error, Its mean Flutter does not locate your ANDROID SDK. There are two folder contain all files of "ANDROID SDK" are "Platform" and "Platform Tools"

在此处输入图片说明

There folder are locate in my computer Here C:\\Users\\ZohaibSaleem\\AppData\\Local\\Android\\Sdk (My name is Zohaib Saleem, you should replace my username folder name with your computer username)

Step 2

Type "Env" in search bar of windows

Click on "System Variable Environment"

在此处输入图片说明

Click on Advanced and Environment Variable在此处输入图片说明

Goto System Vairable -> Path -> Edit在此处输入图片说明

Now paste the path of both folder "platform" and "platform-tools" respectively. In my case path are: C:\\Users\\ZohaibSaleem\\AppData\\Local\\Android\\Sdk\\platforms C:\\Users\\ZohaibSaleem\\AppData\\Local\\Android\\Sdk\\platform-tools

After adding path your System variable look like: 在此处输入图片说明

Click OK Restart PowerShell and again Run command "flutter doctor"

Now, Android SDK problem resolved, but you faced another problem

在此处输入图片说明

For resolve this issue just run command flutter doctor --android-licenses and accept all with "Y". At the end after typing multiple 'Y' again run' flutter doctor' and All set! 在此处输入图片说明

for this issue you have to add 3 variable to Path in the :

  1. C:\\Users\\admin\\AppData\\Local\\Android\\platforms // the path to platform

  2. C:\\Users\\admin\\AppData\\Local\\Android\\platform-tools // the path to platform-tool

  3. C:\\Users\\Admin\\AppData\\Local\\Android\\emulator // the path to emulator

flutter config --android-sdk /your path

example

flutter config --android-sdk /root/Android/Sdk

Tools > SDK Manager > Android SDK

images

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM