The android sdk location cannot be at the filesystem root

Viewed 21629

I have installed Android Studio in the F:\ drive. My Flutter project is in the E:\ drive.

The Flutter plugin is installed in the Android Studio. But when I open my project in Android Studio and I go to the SDK Manager, it shows the following error:

The android sdk location cannot be at the filesystem root

Every package is disabled and the checkboxes are disabled, so I cannot click them to install Android SDK. The "Edit" link next to the error is not working either.

enter image description here

12 Answers

I came with the same problem because of forgetting "sudo"

Using the new android studio (bumble bee version) . Restart the app and make sure you have an internet access That will be enough to create the SDK and it’s directories

Just press Edit ( It is clickable) then download and install the required components.

Download the SDK first, and restore the default settings.

You can find the "Restore default settings" feature here.

I searched for many hours for an answer to this I reinstalled:

  1. I opened a new folder called Android in C:
  2. Into it I reinstalled the android studio
  3. You have created a new SDK folder within it Then in the blank path, I entered C: \ Android \ sdk And that's how it all worked. Try it!

What you can do is that you click on edit to surely you will get some version of Android that installs it by default and you click on next it will open another configuration verification window and you click on the next one for last it will tell you or It will update the version of android that was downloaded by default and you click again to finish and you can just select other versions of Android. That worked for me. Linux Ubuntu 20.04.4 LTS

Step 1:

Step 2:

Step 3:

Step 4:

Ready!!

For me it was the system language on Windows, I have changed it to English and it worked.

TL; DR

Make sure:

  • Your user has write permission into Android SDK directory.
  • ANDROID_HOME is correctly defined with the correct SDK location.

Description

IMHO it is a really bad practice install SDK into user home directory because:

  • Packages added will be restricted to a single user.
  • System administrators won't be able to mirror OS images, thus each engineer will have to install SDK manually.

The old school way is according to Linux directory hierarchy as described at The Linux Documentation Project, which consists on:

  1. Ensure your user has adm privileges
  2. Export SDK environment variables
  3. Obey the filesystem hierarchy, installing the IDE and SDK into /opt

The steps above work perfectly on Ubuntu 22.04 and shall work on other distros with minor adjustments.

1. Ensure your user has adm privileges

grep adm /etc/group | grep ${USER}
adm:x:4:syslog,ventura
lpadmin:x:122:ventura

2. Configure environment variables

/etc/profile.d/
├── ...
├── android.sh
├── ...
├── java.sh
└── ...

where android.sh contains

#!/usr/bin/env bash


export ANDROID_HOME=/opt/google/android/
export FLUTTER_HOME=${ANDROID_HOME}/flutter

TOOLS=${ANDROID_HOME}/platform-tools
TOOLS=${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/tools:${TOOLS}

export PATH=${FLUTTER_HOME}/bin:${TOOLS}:${PATH}

and java.sh your JRE directory

#!/usr/bin/env bash


export JAVA_HOME=/usr/lib/jvm/java-18-openjdk-amd64

3. Install Android Studio and Android SDK

Download latest Android Studio and unpack it into /opt/jetbrains/:

VERSION=2021.2.1.16

sudo mkdir -p /opt/google/android
sudo mkdir -p /opt/jetbrains/studio

# Unpack Android Studio into a versioned folder
tar -xvzf android-studio-${VERSION}-linux.tar.gz
sudo mv android-studio /opt/jetbrains/studio/${VERSION}

# Grant write permission to administrators
sudo chown root:adm -R /opt/jetbrains/
sudo chmod g+w -R /opt/jetbrains/

sudo chown root:adm -R /opt/google/android
sudo chmod g+w -R /opt/google/android

Finally launch Android Studio and choose the SDK location:

android-studio-img

This approach is extremely powerful because it allows system administrators duplicate development workstations using rsync -avz without relying onto any username or custom privileges.

You can clear invalidate caches and restart android studio like follow picture:

enter image description here

Then start download sdk files :)

Make sure that your internet is working and try to close VPN connections if you have any. Then restart Android Studio and hope for the best.

To solve this issue, I had to close Android studio entirely. When I started the application again, it detected that it had a missing SDK problem and then went ahead with the installation process for it.

  1. Your country should not be among the sanctioned countries (using VPN).
  2. Android Studio by Run as Administrator open.
  3. Download : Android SDK and Android SDK Platform.
  4. Fix error: the android sdk location cannot be at the filesystem root.

For test The VPN is working properly. Open website : https://developer.android.com/

Related