12

Error: Failed to complete Gradle execution.

Cause:

Could not create parent directory for lock file C:\Program Files\Android\Android Studio\gradle\gradle-3.2\bin\wrapper\dists\gradle-3.3-all\55gk2rcmfc6p2dg9u9ohc3hw9\gradle-3.3-all.zip.lck

Muthukrishnan Rajendran
  • 11,122
  • 3
  • 31
  • 41
La Vida Sin Amor
  • 121
  • 1
  • 1
  • 7

6 Answers6

8

Edit (2023/01/26):

The equivalent option in IntelliJ 2022.3.1 is now as follows:

  • Setting: "Use Gradle from"
  • Value: "'gradle-wrapper.properties' file"

IntelliJ 2022.3.1 Gradle settings dialog


Original answer:

I just ran into this. In my case, the issue appears to have been caused by using the "Use gradle 'wrapper' task configuration" option in Android Studio/IntelliJ. As this answer suggests, this option causes IntelliJ to override the Gradle wrapper task. The solution for me was to select "Use default gradle wrapper (recommended)" instead.

Fixed IntelliJ Gradle Settings Selection

My suspicion is that this caused a conflict with my customized GRADLE_USER_HOME environment variable for the directory where the final wrapper files actually get stored. For example, Gradle was trying (and failing) to create C:\ProgramData\chocolatey\lib\gradle\tools\gradle-4.5.1\wrapper\dists\gradle-4.5.1-all\87kuriyahurjjkki3zii366f2\gradle-4.5.1-all.zip.lck when run through IntelliJ, but my system uses the file C:\work\.gradle\wrapper\dists\gradle-4.5.1-all\87kuriyahurjjkki3zii366f2\gradle-4.5.1-all.zip.lck when working correctly.

Switching and then running the Gradle refresh through IntelliJ seems to have fixed it. It also succeeds when I switch back to "Use gradle 'wrapper' task configuration", now.

Mike Hill
  • 3,622
  • 23
  • 27
  • As of today, the android studio doesn't have this option. What should be the alternative ? – Muhammad Hanzilah Dec 28 '22 at 19:31
  • @MuhammadHanzilah thanks for pointing that out. Updated answer to include the correct option in more recent versions. – Mike Hill Jan 26 '23 at 18:49
  • 1
    If you are using windows then define the path 1. Go to Setting -> Build, Execution, Deployment -> Build Tools -> Gradle 2. Below General Setting -> define path for Gradle user home: In my case it is inside C:\Users\dell\.gradle. – Bukhari Syed Apr 05 '23 at 11:18
1

For me worked:

In Intellij project folder :

  • delete .idea folder
  • temporary delete gradlew file

Keep it in recycle bin!

Close Ide, then open the project ( it might not work )

Close again, then restore the gradle file / .idea folder.

Message in event log: enter image description here

It shall sync download and work: enter image description here

shareef
  • 9,255
  • 13
  • 58
  • 89
KiteUp
  • 308
  • 3
  • 10
1

I am new to android studio in Mac. This error causing by the folder .gradle is not granted the appropriated right to start working. So open the "get info" and give it all the "Read & write", don't forget to choose "Apply to enclosed items". Hope it help someone !

Remember to active "Apply to enclosed items"

Kartun
  • 21
  • 1
1
  1. Remove the .gradle file (C:\Users\yourname.gradle)
  2. Reinstall the gradle file (create environmental variables path).
  3. Ensure that .gradle file is created properly After that open the android studio run as administration.. it won't show the error
Niroshan
  • 2,064
  • 6
  • 35
  • 60
raunak ali
  • 11
  • 1
0

I did hours of research and I discovered that the localhost:8080 on my program had never fully detached last time I stopped running the program. The program refused to start because really it never stopped from last time. Detach you localhost. If you don't know how just restart the computer--it will detach everything

Kenan
  • 1
  • 1
-5

You can see if your project folder have the permissions set to write and execute. If not, this might work:

sudo chmod 777 path/to/your/projectfolder
Koby Douek
  • 16,156
  • 19
  • 74
  • 103
Thiago
  • 1
  • 1