Gradle 同步失败:包装器属性文件中没有指定键 'distributionUrl' 的值

Gradle sync failed: No value with key 'distributionUrl' specified in wrapper properties file

当我尝试创建一个新项目(在 Kotlin/Java 中)时,出现了这个错误。有人可以帮助我吗?

Gradle sync failed: Could not load wrapper properties from 'C:\Users\gabri\OneDrive\Documentos\TO\MyApplication\gradle\wrapper\gradle-wrapper.properties'. No value with key 'distributionUrl' specified in wrapper properties file 'C:\Users\gabri\OneDrive\Documentos\TO\MyApplication\gradle\wrapper\gradle-wrapper.properties'. java.lang.RuntimeException: Could not load wrapper properties from 'C:\Users\gabri\OneDrive\Documentos\TO\MyApplication\gradle\wrapper\gradle-wrapper.properties'. at org.gradle.wrapper.WrapperExecutor. (WrapperExecutor.java:61) at org.gradle.wrapper.WrapperExecutor.forProjectDirectory(WrapperExecutor.java:38) at org.gradle.tooling.internal.consumer.DistributionFactory.getDefaultDistribution(DistributionFactory.java:62) at org.gradle.tooling.internal.consumer.DefaultGradleConnector.connect(DefaultGradleConnector.java:137) at org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper.getConnection(GradleExecutionHelper.java:502) at org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper.execute(GradleExecutionHelper.java:273) at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:125) at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:60) at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.lambda$resolveProjectInfo[=12=](RemoteExternalSystemProjectResolverImpl.java:35) at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:57) at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:35) at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:44) at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:100) at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:146) at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:132) at com.intellij.openapi.externalSystem.util.ExternalSystemUtil.executeImpl(ExternalSystemUtil.java:544) at com.intellij.openapi.externalSystem.util.ExternalSystemUtil.lambda$execute(ExternalSystemUtil.java:392) at com.intellij.openapi.project.DumbServiceImpl.suspendIndexingAndRun(DumbServiceImpl.java:150) at com.intellij.openapi.externalSystem.util.ExternalSystemUtil.execute(ExternalSystemUtil.java:392) at com.intellij.openapi.externalSystem.util.ExternalSystemUtil.run(ExternalSystemUtil.java:660) at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:888) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess(CoreProgressManager.java:163) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:585) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:531) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:59) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:150) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$run[=12=](CoreProgressManager.java:402) at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:221) at com.intellij.openapi.progress.impl.CoreProgressManager.run(CoreProgressManager.java:402) at com.intellij.openapi.application.impl.ApplicationImpl.run(ApplicationImpl.java:238) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.RuntimeException: No value with key 'distributionUrl' specified in wrapper properties file 'C:\Users\gabri\OneDrive\Documentos\TO\MyApplication\gradle\wrapper\gradle-wrapper.properties'. at org.gradle.wrapper.WrapperExecutor.reportMissingProperty(WrapperExecutor.java:135) at org.gradle.wrapper.WrapperExecutor.readDistroUrl(WrapperExecutor.java:78) at org.gradle.wrapper.WrapperExecutor.prepareDistributionUri(WrapperExecutor.java:67) at org.gradle.wrapper.WrapperExecutor. (WrapperExecutor.java:54) ... 34 more Consult IDE log for more details (Help | Show Log) (56 ms)

有时会发生文件同步不正常之类的情况。

试试这些:

  1. 转到文件 -> 使 Caches/Restart 无效 -> 将项目与 Gradle 文件同步
  2. 转到构建 -> 清理项目 -> 重建项目。

如果这不起作用,那么您项目的 gradle-wrapper.properties 中似乎缺少 distributionUrl。 gradle-wrapper.properties 如下所示。检查您的路径并在 gradle-wrapper.properties 文件

中添加 distributionUrl

可能的解决方案是转到“文件”->“设置”。在设置 window 下选择构建、执行、部署。然后在构建工具下选择 Gradle。单击使用本地 gradle 分发。通过浏览 gradle 位置更改 gradle 家,例如。 ... /gradle/gradle-2.10

计算机上的 ANDROID_HOME 变量设置不正确