12

When I trying to install Android Studio on my PC so the error occurs it says:

The IDE cannot create the directory. Possible reason: parent directory is read-only or the user lacks necessary permissions.

If you have modified the idea.config.path property, please make sure it is correct, otherwise, please re-install the IDE.


Location: C:\Users\Acer/.AndroidStudio4.0/config java.nio.file.AccessDeniedException: C:\Users\Acer.AndroidStudio4.0

enter image description here

Dima Kozhevin
  • 3,602
  • 9
  • 39
  • 52
Amit Chauhan
  • 117
  • 1
  • 1
  • 5
  • You need to install the IDE as administrator permission. it looks that you are trying to install IDE in windows drive so everything which is installed there Must have admin permission. – A Farmanbar Aug 21 '20 at 06:14

15 Answers15

19

I had the same problem but on MacOS, so I thought it might be useful to share the solution for someone who is using Mac like me. Navigate to: /Applications/Android Studio.app/Contents/MacOS, i.e. on terminal execute the following: cd /Applications/Android\ Studio.app/Contents/MacOS then execute: sudo ./studio. This would be enough for the IDE to be executed once so it can create config folder and file. Then everything will be ok.

T-D
  • 1,306
  • 1
  • 16
  • 23
  • 1
    I also tried sudo cmd on my MacAir book . And it worked. But, I had to literally drag the folder path on the terminal, it couldnt make the cd cmd work just by typing the entire path on the terminal... – Dinesh Shewkani Dec 04 '20 at 13:45
  • Running the program using `sudo` is the reason why such problems occur in the first place and is highly not recommended for userland software (due to the obvious security issues). – Slava Fomin II Jun 03 '21 at 11:11
  • 1
    Pretty weird that this is still an issue to this day. Thanks by the way, that helped! – O.S.Kaya Jun 10 '21 at 12:53
  • 1
    This solved my problem:chmod -R 0777 /Users/XXXXX/Library/Application\ Support/JetBrains/Toolbox/apps/PhpStorm/ch-1/212.5284.49/PhpStorm.app – Imeksbank Sep 29 '21 at 00:17
11

I just ran into this bug on a MacBook and to fix it I ran: sudo chmod 777 ~/Library/Application\ Support/Google in the terminal.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Dragos
  • 111
  • 2
  • 3
  • I tried every other mac related answer on this thread and drove myself crazy repeating them all and re installing the application for the better part of a day. I was skeptical of this answer since you had no rep and were at the bottom of the thread with no upvotes but it worked and if i could buy you a meal I would. You're awesome! – Display name Aug 04 '21 at 16:34
  • 2
    A little less invasive version: `sudo chown ~/Library/Application\ Support/Google` – Dirk Bolte Dec 22 '21 at 10:20
  • @DirkBolte Yours should be the accepted answer. – nelsonspbr Aug 05 '22 at 02:43
  • Thanks Brother , You saved the day with this quick solution – Kartiikeya Jul 26 '23 at 05:12
5

The above answer helped me solve it on my machine, but I had to create a directory for Android studio in the designated folder and give that proper permission. Steps

  1. Navigate to username/Library/Google
  2. if there is an AndroidStudio{version} folder, jump to step 3, otherwise create a new folder called AndroidStudio{version} where you swap out the version number. You can find the number in the error message spelled out at the bottom.
  3. right click that folder, and get info.
  4. go to sharing & permissions and give staff+everyone: read-write permission.
Ugglr
  • 61
  • 1
  • 4
  • 1
    This should be top answer. You saved my life, not only this fixed my AS issue, it fixed all the other issues I was having as a result of my migration, *because the Caches folder was not copied over* during migration and everything was running slow and having issues. As soon as I created the Caches folder, a bunch of files automatically got created from different apps, and now everything is running smoothly. I wish I could buy you a beer! – Siavash Feb 02 '21 at 04:43
  • A little less invasive: change the owner from `root` to yourself. – Dirk Bolte Dec 22 '21 at 10:21
4

TLDR:

  • Add read/write permissions to the folder that the IDE mentions.
  • If it does not exist create it
  • Ensure that the folder has READ/Write permissions for your local user.
  • After all this the app would still crash when opening new tabs. So i had to run defaults write com.google.android.studio AppleWindowTabbingMode manual as found in this answer. https://stackoverflow.com/a/64907362/1461176

I ran into this issue recently on Mac OS Sierra. I wasn't comfortable running the app in sudo or setting generic directories like Library/Catches as globally read/write by all users.

cannot create directory The full message was:

The IDE cannot create the directory.
Possible reason: parent directory is read-only or the user lacks necessary permissions.

If you have modified the 'idea.config.path' property, please make sure it is correct,
otherwise, please re-install the IDE.

-----
Location: /Users/username/Library/Application Support/Google/AndroidStudio4.1
java.nio.file.AccessDeniedException: /Users/username/Library/Application Support/Google/AndroidStudio4.1

I have another mac that has Android Studio already setup. So I investigated how it was setup.

The location of the folder was slightly different: /Users/username/Library/Application\ Support/AndroidStudio4.1/.

Notice it's not in the shared Google folder. This shouldn't matter but I believe can be configured with idea.config.path.

The difference in path is probably related to the version of Android Studio that was initially installed.

After opening the permissions on that folder in the working computer, i noticed it had Read/Write for my local user.

Yet the offending computer did not.

Share Permissions did not include my user

I can confirm that editing the permissions fixes this issue and you can reproduce if you remove it.

  • cd to the path output in the error in my case that was: `cd /Users/username/Library/Application Support/Google/AndroidStudio4.1
  • If it does not exist create it sudo mkdir /Users/username/Library/Application Support/Google/AndroidStudio4.1
  • open the parent folder open /Users/username/Library/Application Support/Google/
  • Right click -> Get Info on the /Users/username/Library/Application Support/Google/AndroidStudio4.1
  • Select the lock in the bottom right
  • Select the plus + button on the bottom right.
  • Enter your login password
  • Select your username
  • Change Privilege field for your username to Read/Write
  • Press the lock
  • Close the window
  • Open android Studio

Similar Error If you receive an error related to creating temp files in the the folder the folder is present but it's permissions are still not correct.

cannot create tmp file

Possible reason: the directory is read-only or the user lacks necessary permissions.

If you have modified the 'idea.config.path' property, please make sure it is correct,
otherwise, please re-install the IDE.

-----
Location: /Users/username/Library/Application Support/Google/AndroidStudio4.1
java.nio.file.AccessDeniedException: /Users/username/Library/Application Support/Google/AndroidStudio4.1/ij1547365868.tmp
Sean Dunford
  • 938
  • 1
  • 9
  • 24
2

I had a similar problem on Ubuntu. At first, I tried running ./studio.sh as root. However, I faced other issues down the line. So I cleaned the .cache directory that was created by the root user, also deleted the Google/AndroidStudio* and "Android Open Source Project" under .config. Then I was able to run ./studio.sh without any root permissions.

Amytis
  • 91
  • 4
1

my problem was solved by visiting the C:\Users\Myusername\AppData\Local\JetBrains and giving it the proper permission.

1

This error is caused by permission problem at the spelled out folder at the bottom of the error message.

for Mac, go to YourUserName/Library/Catches. Right click on the catches folder, go to Get Info, and change the "Sharing & Permissions" settings under "everyone" and "staff" to "Read & Write".

neic
  • 145
  • 1
  • 10
0

I had the same issue trying to build a project using capacitor. I was able to fix it simply by adding sudo before the command. So instead of npx cap open android I did sudo npx cap open android and it worked.

Franco
  • 669
  • 2
  • 8
  • 23
0

Also this issue can occur if there is no enough space on your PC. So double check it just to be sure. Generally answer provided by T-D helps to get more descriptive message in that case.

Oleg Novosad
  • 2,261
  • 1
  • 27
  • 28
  • +1. This comment had a downvote but it's exactly the issue I had. Hard drive ran out of space and Android Studio gave me this error – CodeNovice Sep 05 '22 at 08:41
0

On my mac, same error, I deleted this folder:

/Users/xxxxxxxxxxx/Library/Caches/Google

Which was a symlink to /Volumes/RamDisk/Library/Caches/Google

It works perfectly.

Erik
  • 2,500
  • 2
  • 13
  • 26
0

In MacOS the folders inside /Users/<user>/Library/Application Support/ should all be owned by <user>:staff.

In my case /Users/<user>/Library/Application Support/Google was owned by root:staff.

Fixed it by doing: sudo chown <user>:staff /Users/<user>/Library/Application Support/Google

IMO this is a better solution than relaxing the permissions of the folder with chmod 777 like others suggested.

ktorn
  • 1,032
  • 8
  • 14
0

If anyone still facing this issue give chmod 777 permission to the specified paths that error dialog is showing, in my case I had to give permission to Library/Logs and Library/Google

Example:

sudo chmod 777 ~/Library/Logs
sudo chmod 777 ~/Library/Google
0

I think you need to go inside: C:\Users\Acer And Delete AndroidStudio4.0.

Hanif Shaikh
  • 500
  • 1
  • 10
0

On mac some of my folder permissions were blocking me form accessing the folder with android studio. I fixed mine by opening the folder it was complaining about: open ~/Library/Logs/

Then going to its info cmd+i

Then updating the permissions appropriately: enter image description here

bj97301
  • 342
  • 1
  • 13
-1

I've encountered the same issue and here is the solution that worked for me. You need to navigate to where it was initially installed(if installed in the Application folder).

Run this command:

cd /Applications/Android\ Studio.app/Contents/MacOS

then

sudo ./studio