it just sudo,Android Studio:'sudo'不被识别为内部或外部命令,可操作程序或批处理文件...

As a possible solution to my Android Studio "could not expand zip" problem, I would like to run this command from the Terminal window in Android Studio:

sudo chmod -R 777 /your/project/path

However, when I try it, I get this error:

'sudo' is not recognized as an internal or external command, operable

program or batch file.

How to solve? (I am running Android Studio 2.1.2 on Windows 7.)

解决方案

sudo is a *nix utility, not something you'll find on Windows. Ditto chmod.

With that said, the command in question is just adjusting privileges on the project folder using a simple bitmask. From the chmod man page:

-R, --recursive change files and directories recursively

Numeric mode:

From one to four octal digits

Any omitted digits are assumed to be leading zeros.

The first digit = selects attributes for the set user ID (4) and set group ID (2) and save text image (1)S

The second digit = permissions for the user who owns the file: read (4), write (2), and execute (1)

The third digit = permissions for other users in the file's group: read (4), write (2), and execute (1)

The fourth digit = permissions for other users NOT in the file's group: read (4), write (2), and execute (1)

The octal (0-7) value is calculated by adding up the values for each digit

In your command, the first digit is missing so is assumed to be 0. The second, third and fourth are 7, which translates into read/write/execute access for the directory owner, anyone else in the file's group, and anyone else not in the file's group. The -R switch recursively applies those privileges to every file and folder within /your/project/path.

On Windows, the equivalent command is within Explorer. Navigate to /your/project (not /your/project/path) and right-click /path. Choose Properties and a properties dialog will appear. Switch to the Security tab within that dialog.

From here, there are a few ways you could do this. You could simply click your user account from the Group or user names list, hit the Edit button at the bottom of the list, and give yourself any missing privileges.

For a more thorough privilege adjustment, including the recursion your sudo command gives you, choose Advanced instead of Edit. A new dialog, Advanced Security Settings for /path, will appear. Press Change Permissions. The same dialog will reappear, but Change Permissions will be replaced by an Add button and an Edit button. At the bottom, there will be a checkbox labeled Replace all child object permissions with inheritable permissions from this object. Make sure that's checked - that's the -R. Now select your username from the list and choose Edit. Check every checkbox and hit OK. Keep hitting OK all the way back out of the dialogs. With any luck that will be enough to solve your permissions problem.

If you'd like a simpler fix, just run Android Studio as admin, as suggested by the accepted answer in your question. That's somewhat less likely to break things than manually adjusting permissions and is usually enough to work around permissions-related issues in the first place.

Also worth noting, the accepted answer suggests making sure you have write permissions on the android-sdk and Android Studio directories. Only the sudo answer suggests tweaking privileges on /your/project/path. For the sake of the answer I have focused on the Windows equivalent of the command you asked about; you may want to do similar privilege adjustment on android-sdk and Android Studio rather than just /your/project/path.

Finally, be sure android-sdk isn't installed in %PROGRAMFILES%, as write access can be a problem there:

Click Start > All Programs > Accessories , right-click Notepad , and click Run as administrator . For protection against malware, Windows 7 doesn't allow normal processes to change files in the Program Files folder.

Android Studio can safely be installed there, but android-sdk cannot.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值