Could not create parent directory for lock file

喜欢而已 提交于 2020-05-23 10:42:34

问题


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


回答1:


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.

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.




回答2:


For me worked:

in Intellij project folder - delete .idea folder - temporary delete delete gradlew file

restart Idea imported the gradle project again




回答3:


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"



来源:https://stackoverflow.com/questions/45527316/could-not-create-parent-directory-for-lock-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!