Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android update causing error: Error:java.nio.file.AccessDeniedException: /home/path/.android/build-cache.lock

Updated Android Studio from version 2.3 to 3.1 Canary. But there seems to be a huge problem with Gradle.

Error:java.nio.file.AccessDeniedException: /home/pathname/.android/build-cache.lock

What I did:

  1. Deleted .gradle, thought it will solve the issue, but not, after rebuilding the project, .gradle again appears.
  2. Deleted all android related things from system (SDK, Android Studio and remaining projects) and from zero started to download Android Studio with all required packages. Still, the same problem.
  3. Changed android studio version from 3.1 canary to 3.0, also no success.
  4. Looked at this post, but didnt help.
  5. Read in some posts that this happens when Android Studio is corrupted. but I have downloaded from official site.

Any ideas how to fix it?

like image 841
Zafar Kurbonov Avatar asked Nov 07 '17 17:11

Zafar Kurbonov


People also ask

What is accessdeniedexception in Java NIO?

java.nio.file.AccessDeniedException​ ​This issue occurs if the agent is unable to access the required files/folders that are needed for deployment of Data Integration Services. Solution 1) For Solution, enter CR with a Workaround if a direct Solution is not available.

Why is Android Studio not working on my Device?

Android Studio Beta works, but the standard version is giving this errors! Make sure that C:\Users\kunal\Desktop\Workspace is accessible (readble/writable) to android studio. Check the directories' permissions and if they exist.

Why can't I Find my Android Studio Folder in Kunal?

Make sure that C:\Users\kunal\Desktop\Workspace is accessible (readble/writable) to android studio. Check the directories' permissions and if they exist. I did that still no luck! : ( Default Directory for applications folder works but this doesn't! Worked for me.

Why does the IDE fail to install some plugins?

When I restarted the IDE, i got the following Plugin Installation Error: The IDE failed to install some plugins. Most probably, this happened because of a change in a serialization format. The cause: java.nio.file.AccessDeniedException: C:\Users aylojon\AppData\Roaming\JetBrains\PyCharm2021.2\plugins\IdeaVim\lib\IdeaVIM-1.8.0.jar


Video Answer


4 Answers

Open Android Studio as administrator..it worked for me.

like image 111
theavatar Avatar answered Oct 13 '22 23:10

theavatar


I got the same error trying to Sync the project after an update. What solved the problem was giving the right permission to the .android folder, instead of running the studio on root mode (It would reinstall all SDK under root if you don't specify that you already have it under you user).

So, open the terminal and type:

sudo chown -R root:YOURUSERNAME /home/YOURUSERNAME_FOLDER/.android/
sudo chmod -R 775 /home/YOURUSERNAME_FOLDER/.android/

Easy fix, I hope it helps somebody.

like image 21
Ailison Carvalho Avatar answered Oct 14 '22 01:10

Ailison Carvalho


Solved, in Linux I changed ownership and mode of the directory to that of below:

sudo chown MyUserName:MyUserName // This allows to change from administrator access to user access. Note it should be executed from there, where your android studio is located. Either it might be in /Home or /Download folder

sudo chmod -664 //This allowed files to be readable and writeable.

Reinstallation or other extra stuff dont seem to help, unless you do deal with proper root specification and file mode.

like image 26
Zafar Kurbonov Avatar answered Oct 14 '22 00:10

Zafar Kurbonov


You can either start Android Studio as an Administrator. But this might be just a workaround and is not practically for some people. Fortunately, there is another way of avoiding this problem:

  1. Open Explorer
  2. Go to the folder where the build-cache file is located
  3. Right-Click on it
  4. Change the permissions for the file to have full access as a User

This should solve the problem and worked great with a similar problem (android.lock file actually!)

like image 37
Matthäus Schwarzkogler Avatar answered Oct 13 '22 23:10

Matthäus Schwarzkogler