69

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.

vm345
  • 813
  • 12
  • 28
spark
  • 1,271
  • 1
  • 12
  • 18

15 Answers15

176

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

Sathyajith
  • 3,836
  • 3
  • 15
  • 28
  • 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 '17 at 01: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 '18 at 04:10
  • 1
    As simple as that, Thank you - Tatiana style- – Hanako Sep 01 '18 at 00:12
  • 1
    On Windows I manually had to create an empty repositories.cfg inside c:\users\me\.android – Matthias Güntert Sep 15 '18 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 '21 at 22:03
65

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

I solved this issue by setting ownership to myself

sudo chown $USER:$USER $ANDROID_HOME -R

hannes ach
  • 16,247
  • 7
  • 61
  • 84
  • 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 '18 at 10:12
  • 8
    `sudo chown $USER: $ANDROID_HOME -R` should be enough – Piterden Aug 23 '18 at 18:10
  • 1
    This worked for me, and I replaced the deprecated `$ANDROID_HOME` with `$ANDROID_SDK_ROOT`. – tyler.frankenstein Nov 16 '20 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 '21 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 '21 at 06:16
25

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.

spark
  • 1,271
  • 1
  • 12
  • 18
  • 1
    how to set permission of that folder? – Qadir Hussain Sep 06 '17 at 20:19
  • link to set permissions https://winaero.com/blog/how-to-take-ownership-and-get-full-access-to-files-and-folders-in-windows-10/ – Amna Mirza Sep 14 '17 at 06:58
  • 11
    This is more of a workaround than a solution. Setting such permissions is a security problem. – martinkunev Dec 13 '17 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](https://stackoverflow.com/a/44382514/3672398) – Blockost Sep 09 '18 at 16:21
  • `777` will make all files executable. Why not use `go=u` or `ugo=rwX` instead? – Martin Feb 18 '21 at 12:20
11

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

Francis Bacon
  • 4,080
  • 1
  • 37
  • 48
4

for macos:

sudo chmod -R 777 ~/Library/Android
Pnemonic
  • 1,685
  • 17
  • 17
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.

pat
  • 1,947
  • 2
  • 14
  • 18
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.

datoml
  • 5,554
  • 4
  • 21
  • 28
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.

Chris Moore
  • 51
  • 1
  • 5
1

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

Taskmaster
  • 966
  • 8
  • 16
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.

Kossei Necira
  • 41
  • 1
  • 6
0

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

Shmuel Kamensky
  • 411
  • 1
  • 5
  • 13
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