vnshetty
vnshetty

Reputation: 20132

Android-studio Selected directory is not valid home for Android SDK

I installed android studio but while selecting android SDK I am getting following error. I tried solution which is on this post but no luck. How can I solve this?

error screenshot 1

error screenshot 2

Upvotes: 28

Views: 82176

Answers (16)

Asad Raza
Asad Raza

Reputation: 1

Are you encountering the "Selected directory is not a valid home for Android SDK" error in Android Studio, and you suspect that the issue may be related to spaces in your user profile name? We've got you covered!

This error typically occurs when Android Studio cannot locate or recognize the Android SDK installation directory. One common reason for this error is having a user profile name with spaces. Android Studio might struggle with directory paths containing spaces, which can lead to this issue.

To resolve this problem, follow these steps:

1. Rename Your User Profile (Optional):

If you're comfortable with it, consider renaming your user profile to remove spaces. You can do this by going to your computer's settings or control panel, then navigating to the "User Accounts" or "Accounts" section. Choose "Change your account name" and follow the prompts to rename your profile.

2. Create a Symbolic Link (Symlink):

If you'd rather not change your user profile name, you can create a symbolic link (symlink) to work around the issue. Here's how:

First, open a Command Prompt or Terminal window with administrator or superuser privileges.

Navigate to your Android SDK directory. This is usually located in the

C:\Users<YourUserName>\AppData\Local\Android\Sdk

directory on Windows or

/Users//Library/Android/sdk

on macOS.

Create a symlink to your Android SDK directory without spaces in the name. For example, if your user profile name is "John Doe," you can create a symlink like this on Windows:

mklink /d C:\Users\JohnDoe\AppData\Local\Android\Sdk C:\Users\John Doe\AppData\Local\Android\Sdk

Or on macOS/Linux:

ln -s /Users/JohnDoe/Library/Android/sdk /Users/John\ Doe/Library/Android/sdk

3. Reconfigure Android Studio:

After creating the symlink, open Android Studio. Go to "File" > "Project Structure." Under "SDK Location," click on "Edit" and update the Android SDK location to point to the symlink you created (e.g., C:\Users\JohnDoe\AppData\Local\Android\Sdk on Windows or /Users/John Doe/Library/Android/sdk on macOS).

4. Apply Changes and Restart:

Apply the changes and restart Android Studio.

Upvotes: -1

Stan
Stan

Reputation: 2181

With Android Studio 4.1.2 the easiest thing is to close the project (file / close project). That's how you get to the wizard that automatically sets up the SDK for you.

The default location that it suggests is /Users/stan/Library/Android/sdk (exactly the same that I was trying to set up manually but AS kept saying it's invalid)

Upvotes: 0

Helvio Hild
Helvio Hild

Reputation: 61

  1. Close error window
  2. Go to gradle tab
  3. select "Gradle settings", wrench icon
  4. Search for SDK setup
  5. Select appropriate sdk for your device.
  6. Next, two times
  7. Wait for install There is all..

Upvotes: 6

Shikha Kothiyal
Shikha Kothiyal

Reputation: 1

Steps to follow:

  1. Close Android Studio.
  2. Restart Android Studio and Give the path of Empty Folder .
  3. Install Sdk in that folder(Sdk will automatically install and will get configure automatically.)

Upvotes: 0

Ruben Palavecino
Ruben Palavecino

Reputation: 720

In my case I wasn't giving him admin permission

Upvotes: 0

user9888797
user9888797

Reputation: 99

Just delete(preferably permanently) all the android directories in whatever location they are present(e.g. C:\Program Files\Android, C:\users\respective user\respective android folders). Remove the installer as well(if possible). Make sure to save all your Android Studio files in some external storage (preferably).

The main thing is to get Android studio with SDK.

Now go to the android studio website and install android studio leaving all settings default. There you will also get to install the SDK and it's linking.

It will take some time to load and will load nearly 1.5 GB files.

This worked for my case.

Upvotes: 0

abelabbesnabi
abelabbesnabi

Reputation: 1817

None of the other answers work. After the installation, immediately close Android Studio, then start it as administrator. A message might popup asking for the sdk manager location. Ignore it (Close the popup). Go to Tools > SDK Manager and click on the edit button on the right of Android SDK Location. Then click Next, next and you're good to go. Android Studio will let you install the sdk manager.

enter image description here

Upvotes: 2

user3762527
user3762527

Reputation: 99

I resolved with the instructions here, http://www.blog.teamguru.in/2018/04/06/selected-directory-is-not-a-valid-home-for-sdk/

  1. Just close current error window and let run the android studio
  2. Open the SDK manager as shown below
  3. Click on Edit SDK location as shown below
  4. Simply press next button if there is correct location for SDK you want to install there
  5. Let it be downloaded
  6. Install platform and SDK tools and
  7. Enjoy

Upvotes: 10

Leandro
Leandro

Reputation: 376

The sdk folder contains the platform-tools folder.
I copied this folder and named it platforms, then it worked for me.

Upvotes: 0

Itai Ganot
Itai Ganot

Reputation: 6305

If like me, a MacOs user which has installed Android Studio on my Mac and if you've tried everything you can think of but was still unable to set the Android SDK directory in Android Studio, follow the next steps (I know the site where I got the bundle is a freeware site but the package is the right one):

1. Download adt-bundle-mac (Android Developer Tools) from [here][1].
2. Unzip the file and browse into the unzipped folder.
3. Copy only the sdk dir to /Users/username/Library/Android 
4. Open Android Studio, the error about the SDK folder which is not set will pop up, set the path to the SDK to "/Users/username/Library/Android/sdk".
5. Now Android Studio will accept the path and you're good to go.

I wasted about 2 hours until I fixed it so I hope that by writing this answer I'll save you some 2 hours.

Upvotes: 0

EffyCoder
EffyCoder

Reputation: 48

I had the same problem but what I found is that it requires the parent folder of the following things AVD manager,SDK manager,tools,platform-tools,build-tools etc.So what you need is to find the parent directory of these things, which you might find with a name such as android-sdk or android-sdk-windows(in case you are using windows OS).Make sure the above said contents are in that folder and select it.I hope you will find this useful.

Upvotes: 1

Thomas
Thomas

Reputation: 181705

I had this problem on Linux. Apparently you need write access to some place in that directory, so I just took ownership of the entire thing:

sudo chown -R thomas:thomas /opt/android-sdk

Could be that something similar is going on on Windows as well.

Upvotes: 0

53iScott
53iScott

Reputation: 857

I got the same issue. You must enable the Android Support Plugin Configuration > Plugin > Android Support Plugin. Check it.

Upvotes: 6

Abbath
Abbath

Reputation: 1012

I had this problem, select SDK folder (NOT SDK->sources or SDK-platforms)

Upvotes: 16

narasi
narasi

Reputation: 463

Try restarting the application. Close all related studio processes, then right click "run as administrator".

You should be fine after this.

Upvotes: 5

Jakob Eriksson
Jakob Eriksson

Reputation: 18767

Download the SDK from http://developer.android.com/sdk/index.html

Start SDK manager and make everything up to date

Also, make sure you have set the language level to

  • 7.0 Diamonds, ARM, Multi-catch, etc

Upvotes: 0

Related Questions