本文介绍了Android Studio设置 - 清除只读状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

没有获得写入某个文件夹的权限。 Android Studio问这个问题。只有我可以点击取消按钮。





之后,当我想离开Android Studio时,我得到无法保存项目。






  • 项目从git仓库下载。

  • 在其他mac上工作正常。
  • 项目下载到user / projects /项目名称。

  • 尝试使用权限不成功

  • 尝试更改项目目录位置(同一目录中的另一个项目正在运行) / li>
  • 安装所有可能的软件包





Android Studio中的锁定图标。





我需要任何建议以寻找解决方案的方向?

解决方案

最可能的解释是该目录及其所有文件都由系统上的其他用户帐户拥有。通常情况下,如果可以这样做,清除只读访问对话框将修复读取权限问题;如果它不是(因为这些文件是由另一个用户拥有的话),对话框将拒绝让你点击OK按钮。



您可以通过使用 ls 命令从MacOS终端。这是我的一个随机项目的例子。

  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 1月9日10:54 gradle

如果您运行 man ls ,您可以阅读 ls 命令的手册页,并获取更多关于从命令输出,但每个文件输出中的单个w字符告诉我这些文件只能由文件所有者写入。这些文件全部由foo用户拥有(这是第三列输出的含义)。当我运行Android Studio时,我不是foo,因此我无法写入这些文件,因为我不是foo,所以我没有权限给自己写入权限。



您可以使用以下命令修复它。在运行此命令时要非常小心地使用正确的路径;如果你犯了一个错误,在 sudo 下进行大规模文件系统更改可能会造成很大的损失。

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

可能有一种方法可以通过Finder UI修复此问题,但命令行非常简单。



它会要求您输入管理员密码,然后它会让您成为这些文件的所有者,并且清除只读状态对话框应该适用于您。


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

Afterwards, when I want to leave Android Studio I get "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

Locked icons in Android studio.

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

解决方案

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.

这篇关于Android Studio设置 - 清除只读状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 11:10