Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio setup - Clear Read-Only Status

Permission to write to certain folder isn't obtained. Android Studio asks this. Only thing I can click on "Cancel" button.

Clear read only-status

Afterwards, when I want to leave Android Studio I get "could not save project".

Could not save project

  • Project is downloaded from git repository.
  • Works fine on other macs.
  • Project is downloaded to user/projects/project-name.
  • Tried to play with permissions without success
  • Tried to change project directory location (another project in the same directory is working)
  • Installed all possible packages

Permissions on files in project folder

Locked icons in Android studio.

enter image description here

I need any suggestion in what direction to look for solution?

like image 782
Ante Avatar asked Feb 06 '14 15:02

Ante


People also ask

How to edit read-only class in Android Studio?

You can click on the lock icon to toggle the READ-ONLY Option. The option can be found at the BOTTOM-RIGHT Corner of the Android Studio.

Can you change a file from read-only?

Remove the read-only attributeSome read-only files can be changed to allow for edits by removing the read-only attribute in the file properties. Right-click the file and select Properties. Uncheck the box for Read-only and click OK.

What does the attribute read-only mean?

Read-only is a file attribute which only allows a user to view a file, restricting any writing to the file. Setting a file to “read-only” will still allow that file to be opened and read; however, changes such as deletions, overwrites, edits or name changes cannot be made.


1 Answers

The most likely explanation is that the directory and all its files are owned by a different user account on the system. Normally the "Clear Read-Only Access" dialog will fix up read permission problems if it's possible to do so; if it's not (because the files are owned by another user), the dialog will refuse to let you click the OK button.

You can confirm this by using the ls command from the MacOS terminal. Here's an example from a random project of mine.

sbarta-macbookpro2:~/AndroidStudioProjects/ASProject$ ls -alh total 80 -rw-r--r--  1 foo   eng   438B Jan  9 10:54 local.properties -rw-r--r--  1 foo   eng   853B Jan  9 10:54 gradle.properties drwxr-xr-x  3 foo   eng   102B Jan  9 10:54 gradle 

If you run man ls you can read the man page for the ls command and get a lot more information on the output from the command, but the single "w" character in the output for each file tells me that those files are only writable by the file's owner. Those files are all owned by the foo user (which is what the third column of output means). I'm not foo when I'm running Android Studio, so I can't write to those files, and since I'm not foo, I don't have permissions to give myself write access to them.

You can fix it with the following command. Be very careful you use the correct path when you run this command; making large-scale filesystem changes under sudo can do a lot of damage if you make a mistake.

sudo chown -R $USER /path/to/project/directory 

There's probably a way to fix this through the Finder UI, but the command-line is pretty easy.

It will ask you for an administrator password, and after that it should make you the owner of those files and the "Clear Read-Only Status" dialog should work for you.

like image 146
Scott Barta Avatar answered Sep 22 '22 05:09

Scott Barta