74

Screenshot of error

enter image description here

I am running [ Android Studio 2.3 Build #AI-162.3764568, built on February 24, 2017 JRE: 1.8.0_112-release-b06 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o] on Ubuntu 16.04. From last few days android studio gives me error on trying to update. I have no idea how to fix this.

15 Answers 15

185

I ran the Android studio as administrator and then it worked as it is a permission issue.

4
  • 1
    Thanks for the tip. I seem always to forget setting AS to run as an administrator after each installation on a Windows PC.
    – Hong
    Nov 28, 2017 at 1:50
  • 14
    or sudo if you're on command line: cd into $ANDROID_HOME$/sdk/tools/bin and sudo bash sdkmanager "platforms;android-26" "build-tools;26.0.1"
    – Yibo Yang
    Mar 13, 2018 at 4:10
  • 1
    On Windows I manually had to create an empty repositories.cfg inside c:\users\me\.android Sep 15, 2018 at 23:09
  • 2
    For Windows 10 to always run as administrator: 1- go to the startup location (something like C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Android Studio) 2- right-click the shortcut 3- select 'Troubleshoot Compatibility' 4- tick the box next to 'The application requires additional permissions' 5- click 'Test the program' (the program will start and the administrator confirmation dialog will appear) 6- after confirming, go back to the compatibility troubleshooter and click 'Next' 7- select 'Yes, save these settings for this program'. Now it will always run as administrator.
    – nallan
    Aug 31, 2021 at 22:03
69

chmod 777 $ANDROID_HOME -R This is not a good solution like @spark mentioned.

I solved this issue by setting the ownership to myself

sudo chown $USER:$USER $ANDROID_HOME -R

6
  • You should not change the directory ownership unless you have installed the SDK in that user's directory. Invoking sudo chown tells me otherwise.
    – pat
    Mar 13, 2018 at 10:12
  • 8
    sudo chown $USER: $ANDROID_HOME -R should be enough
    – Piterden
    Aug 23, 2018 at 18:10
  • 1
    This worked for me, and I replaced the deprecated $ANDROID_HOME with $ANDROID_SDK_ROOT. Nov 16, 2020 at 20:22
  • Changing the group instead of the owner and using g=u as permission might be a less invasive option. Making all files executable is not a very good idea.
    – Martin
    Feb 18, 2021 at 12:19
  • 2
    On OSX, this command worked for me: sudo chown -R $USER: $ANDROID_HOME. The -R had to be moved at the front.
    – Vinayak
    Mar 23, 2021 at 6:16
26

Problem Solved!

The permission of my Android directory was set to write only by root so android-studio was unable to write any changes. I changed the permissions to 777 and it fixed the problem.

Thanks for Help anyways.

5
  • 1
    how to set permission of that folder? Sep 6, 2017 at 20:19
  • link to set permissions winaero.com/blog/…
    – Amna Mirza
    Sep 14, 2017 at 6:58
  • 11
    This is more of a workaround than a solution. Setting such permissions is a security problem. Dec 13, 2017 at 18:00
  • 2
    As stated by some people here already, setting folder permissions (and sub-folders using -R) to 777 is like saying "OK guys, this is free for all now!". The accepted solution should be the one proposed by @SAJ
    – Blockost
    Sep 9, 2018 at 16:21
  • 777 will make all files executable. Why not use go=u or ugo=rwX instead?
    – Martin
    Feb 18, 2021 at 12:20
12

Solution 1:

Use: sudo chown $USER: $ANDROID_HOME -R

My solution is setting folder permissions (and sub-folders using -R).

Root cause:

The permission of my Android SDK directory was set to write only by root so android-studio was unable to write any changes.

Detailed Process:

Take $ANDROID_HOME/platform-tools for example:

sudo chown $USER: $ANDROID_HOME/platform-tools

Before executing the command line:

before executing the sudo chown

bin ls -la $ANDROID_HOME/
total 56
drwxr-xr-x@  26 gongzelong  staff    832 Nov  3 01:51 .
drwx------@ 104 gongzelong  staff   3328 Nov  6 17:55 ..
-rw-r--r--@   1 gongzelong  staff  18436 Oct 26 21:17 .DS_Store
drwxr-xr-x    2 gongzelong  staff     64 Nov  4 01:47 .downloadIntermediates
-rw-r--r--    1 gongzelong  staff     16 Nov  6 17:46 .knownPackages
drwxr-xr-x   41 gongzelong  staff   1312 Nov  4 23:08 .temp
-rw-r--r--@   1 gongzelong  staff   1158 Aug 30  2018 SDK Readme.txt
drwxr-xr-x@   2 gongzelong  staff     64 Aug 29  2016 add-ons
drwxr-xr-x@  34 gongzelong  staff   1088 Nov  3 01:47 build-tools
drwxr-xr-x@   6 gongzelong  staff    192 Apr 24  2019 cmake
drwxr-xr-x@  51 gongzelong  staff   1632 Oct 24  2016 docs
drwxr-xr-x   17 root        wheel    544 Nov 12  2019 emulator
drwxr-xr-x@   8 gongzelong  staff    256 Jul 31  2018 extras
drwxr-xr-x@   3 gongzelong  staff     96 Nov  7  2017 fonts
drwxr-xr-x@   9 gongzelong  staff    288 Apr 21  2020 licenses
drwxr-xr-x@   6 gongzelong  staff    192 Apr 24  2019 lldb
drwxr-xr-x    7 gongzelong  staff    224 Nov  4 22:47 ndk
drwxr-xr-x@  20 gongzelong  staff    640 Sep 29  2018 ndk-bundle
drwxr-xr-x@   5 gongzelong  staff    160 Dec 15  2016 patcher
**drwxr-xr-x   19 root        wheel    608 Nov 12  2019 platform-tools**
drwxr-xr-x@  16 gongzelong  staff    512 Nov  3 01:47 platforms
drwxr-xr-x@  33 gongzelong  staff   1056 Feb 17  2020 skins
drwxr-xr-x@  14 gongzelong  staff    448 Nov  3 01:51 sources
drwxr-xr-x@  13 gongzelong  staff    416 Apr  8  2019 system-images
drwxr-xr-x@   2 gongzelong  staff     64 Feb  4  2018 temp
drwxr-xr-x   15 gongzelong  staff    480 Oct 26 21:18 tools

After executing the command line:

after executing the sudo chown

➜  bin ls -la $ANDROID_HOME/
total 56
drwxr-xr-x@  26 gongzelong  staff    832 Nov  3 01:51 .
drwx------@ 104 gongzelong  staff   3328 Nov  6 17:55 ..
-rw-r--r--@   1 gongzelong  staff  18436 Oct 26 21:17 .DS_Store
drwxr-xr-x    2 gongzelong  staff     64 Nov  4 01:47 .downloadIntermediates
-rw-r--r--    1 gongzelong  staff     16 Nov  6 17:46 .knownPackages
drwxr-xr-x   41 gongzelong  staff   1312 Nov  4 23:08 .temp
-rw-r--r--@   1 gongzelong  staff   1158 Aug 30  2018 SDK Readme.txt
drwxr-xr-x@   2 gongzelong  staff     64 Aug 29  2016 add-ons
drwxr-xr-x@  34 gongzelong  staff   1088 Nov  3 01:47 build-tools
drwxr-xr-x@   6 gongzelong  staff    192 Apr 24  2019 cmake
drwxr-xr-x@  51 gongzelong  staff   1632 Oct 24  2016 docs
drwxr-xr-x   17 root        wheel    544 Nov 12  2019 emulator
drwxr-xr-x@   8 gongzelong  staff    256 Jul 31  2018 extras
drwxr-xr-x@   3 gongzelong  staff     96 Nov  7  2017 fonts
drwxr-xr-x@   9 gongzelong  staff    288 Apr 21  2020 licenses
drwxr-xr-x@   6 gongzelong  staff    192 Apr 24  2019 lldb
drwxr-xr-x    7 gongzelong  staff    224 Nov  4 22:47 ndk
drwxr-xr-x@  20 gongzelong  staff    640 Sep 29  2018 ndk-bundle
drwxr-xr-x@   5 gongzelong  staff    160 Dec 15  2016 patcher
**drwxr-xr-x   19 gongzelong  wheel    608 Nov 12  2019 platform-tools**
drwxr-xr-x@  16 gongzelong  staff    512 Nov  3 01:47 platforms
drwxr-xr-x@  33 gongzelong  staff   1056 Feb 17  2020 skins
drwxr-xr-x@  14 gongzelong  staff    448 Nov  3 01:51 sources
drwxr-xr-x@  13 gongzelong  staff    416 Apr  8  2019 system-images
drwxr-xr-x@   2 gongzelong  staff     64 Feb  4  2018 temp
drwxr-xr-x   15 gongzelong  staff    480 Oct 26 21:18 tools

Then we do the update in SDK management: Before update

updaing the sdk 1

updaing the sdk 2

update successfully

before and after install sdk result screenshot

before and after install result screenshot

Solution 2:

Run Android Studio as administration.

sudo /Applications/Android\ Studio\ 4.1.0.app/Contents/MacOS/studio

It could also install the android sdk update successfully

before updating update successfully check and confirm the result

4

for macos:

sudo chmod -R 777 ~/Library/Android
3
  • Awesome! Worked for me :) yay..! Oct 1, 2019 at 4:23
  • 1
    This will only work if your ANDROID_HOME is ~/Library/Android 😉 — and 777 is a bit over the top. g=u (set group to user) might be a less invasive option.
    – Martin
    Feb 18, 2021 at 12:16
  • Just look for a directory with wrong permissions and chown it.
    – nyxee
    Mar 18, 2022 at 10:13
3
  1. Delete old version
  2. Reboot
  3. Install new version

hope this helps :)

3

If you are on a *nix system, you should locate $ANDROID_HOME. Mine is installed inside /opt. Given that this directory belongs to root, you will need to invoke sudo before running your command.

2

I had the same issues on windows and the problem for me was where the SDK was related.

When you go to File - Project Structure - Android SDK Location you can see what SDK directory is defined. The default SDK location was C:\Program Files (x86)\Android\android-sdk and it seems you need to be an Administrator to be able to download packages.

I changed it to my user directory so I don't need admin privileges and I was able to download the required packages without any problems.

Also make sure you accpeted all licences before.

1
  • 1
    Running Android Studio with administrator privileges worked for my case. Feb 17, 2022 at 11:29
2

I was unable to update the platform-tools and emulators. What I found was there was an .installer directory in each of those directories. Deleting those allowed the update to complete.

Rogue .installer directory in platform-tools

Rogue .installer directory in emulator

1
  • Thanks for that tip. I tried any other solution regarding fixing permissions but nothing solved my error. But deleting those ".installer" directories solved it finally.
    – Pepper
    Mar 18 at 17:01
1

I ran in to this issue and when I navigated to the existing install of the SDK I found that it was symlinked to a previous version that I installed using Homebrew (which is no longer supported).

The fix was to remove this symlink, then Android Studio was able to install the updated SDK as expected.

0

I was facing the same problem, I solved it by first enabling the "Force https://... sources to be fetched using http://..." setting in the SDK Manager Tools > Options menu. and then I opened Android Studio as administrator.

0

I faced a similar problem when I tried to install new packages using SDK Manager in the Android command line tool.

Error: failed to read or create install properties file in SDK manager.

The problem occurred because the SDK manager cannot figure out how to validate licenses without administrator permissions.

Solution: Run the command line as an administrator.

0

I fixed this on linux by running sudo chown /opt/android-sdk Change /opt/android-sdk to the path of your android sdk

0

I had a fresh Installation of Android Studio. I ran the install script with root access the first time so my SDK files went buggy and the next time I opened Android Studio, It opened with regular user permissions and I was unable to update the SDK.

I just deleted the initial SDK folder and let the studio download it again and the problem was gone.

-3

In windows, you may run Android Studio as Administrator

1
  • 11
    The OP is running Ubuntu, and randomly running programs with elevated permissions is never a good idea
    – Nico Haase
    Mar 29, 2018 at 7:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.