7

I checked out a git repository in android studio, but I'm in trouble with Gradle sync failed error.

When project wants to build, the android studio raise an error like as following:

Gradle sync failed: Could not create parent directory for lock file 
C:\Users\username\.gradle\wrapper\dists \gradle-4.10.1- 
all\455itskqi2qtf0v2sja68alqd\gradle-4.10.1-all.zip.lck
  • I saw some answers to the other almost same problems, but none of them help.
  • Also I deleted cashes in .gradle directory according above path, but it does not work.

How can I solve this problem?

I appreciate you to solve this problem, thanks.

Halil Ozel
  • 2,482
  • 3
  • 17
  • 32
Amin Soheyli
  • 605
  • 2
  • 7
  • 16

6 Answers6

3

Remove C:\Users\yourname.gradle

then close android studio and Start Android Studio with administrative permission.

it fixed in my case.

Nikul Vadher
  • 129
  • 1
  • 9
3

Yes It's working for me try this.

For anyone who still encountering this issue, I have just ran the Android Studio as administrator and it worked.

Sajid Ali
  • 31
  • 1
2

For anyone who still encountering this issue, I have just ran the Android Studio as administrator and it worked.

1

Run this following command:

gradlew clean
gradlew assembleDebug

If this does not work use following command.

gradlew --update-locks assembleDebug
Suraj Kumar
  • 5,547
  • 8
  • 20
  • 42
Ranjan Kumar
  • 1,164
  • 7
  • 12
1

I found this answer:

  1. In the upper-right corner of android studio click on the Gradle tool, then right click on the your project name then click on the Refresh Gradle project as following:

Gradle --> Your project name --> Refresh Gradle project

  1. Then click on the Build -> Rebuild Project as following:

Build --> Rebuild Project

Amin Soheyli
  • 605
  • 2
  • 7
  • 16
  • This solution does not apply to the issue you have mentioned. You mentioned permission issues that would be solved by running Android Studio in Administrator mode. Refreshing and Rebuilding throw the same "Could not create parent directory for lock file" error. I just had the same issue and fixed it by running Android Studio in admin mode. – Bruno Jul 22 '22 at 21:01
1

Same issue had troubled me long enough before I found this link for same issue in Intellij. After going the conversation, I found this is a permissions issue - which I should have figured out as the error clearly says "Failed to create parent directory".

I simply gave required permissions to the gradle directory and it worked. Similar to below(replace path_to_gradle to your actual path) :

chmod ugo+rwx <path_to_gradle>

nanosoft
  • 2,913
  • 4
  • 41
  • 61