Reputation: 651
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
How can I solve this problem?
I appreciate you to solve this problem, thanks.
Upvotes: 9
Views: 32399
Reputation: 1
For Linux Ubuntu users. I was able to fix by adjusting Android Studio Gradle Settings to point to /home/YOUR-USERNAME/.gradle/
Upvotes: 0
Reputation: 664
In my case, the Gradle user home
field was changed to a non-default folder. However, that folder is NOT existed anymore (due to disk partition or something similar). Then, just remove the non-default folder to make Android Studio download Gradle stuff again to default folder - C:\Users\user-name\.gradle
(or you can specify any other new valid folder I think).
Upvotes: 2
Reputation: 29
Delete '.gradle' file from the location C:\Users\your_computer_name.gradle After deletion the .gradle file close the Android studio. And open the Android studio Problem is fix
Upvotes: -1
Reputation: 3091
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>
Upvotes: 1
Reputation: 49
For anyone who still encountering this issue, I have just ran the Android Studio as administrator and it worked.
Upvotes: 3
Reputation: 139
Remove C:\Users\yourname.gradle
then close android studio and Start Android Studio with administrative permission.
it fixed in my case.
Upvotes: 4
Reputation: 1210
Run this following command:
gradlew clean
gradlew assembleDebug
If this does not work use following command.
gradlew --update-locks assembleDebug
Upvotes: 0
Reputation: 651
I found this answer:
Gradle
tool,
then right click on the your project name
then click on the Refresh Gradle project
as following:Build -> Rebuild Project
as following:Upvotes: 1