问题描述
错误:无法完成Gradle执行.
原因:
我刚遇到这个问题.就我而言,该问题似乎是由于使用Android Studio/IntelliJ中的使用gradle'包装器"任务配置"选项引起的.作为
我怀疑这与我为最终存储包装文件的目录自定义的 GRADLE_USER_HOME
环境变量造成了冲突.例如,Gradle尝试(但失败)创建 C:\ ProgramData \ chocolatey \ lib \ gradle \ tools \ gradle-4.5.1 \ wrapper \ dists \ gradle-4.5.1-all \ 87kuriyahurjjkki3zii366f2 \ gradle-通过IntelliJ运行时为4.5.1-all.zip.lck
,但是我的系统使用文件 C:\ work \ .gradle \ wrapper \ dists \ gradle-4.5.1-all \ 87kuriyahurjjkki3zii366f2 \ gradle-4.5.1-all.zip.lck
正常工作时.
切换并通过IntelliJ运行Gradle刷新似乎已解决了该问题.现在,当我切换回使用gradle'包装器'任务配置"时,它也会成功.
Error: Failed to complete Gradle execution.
Cause:
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.
这篇关于无法为锁定文件创建父目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!