[英]Android Studio: Unable to build app due to gradle distribution url error
I know this question has been asked before but I haven't been able to fix the issue.我知道之前有人问过这个问题,但我一直无法解决这个问题。 I am running Android Studio version 3.1.4.我正在运行 Android Studio 3.1.4 版。 I am trying to run an app that I cloned from a Github repository.我正在尝试运行从 Github 存储库克隆的应用程序。 But even before I try to run it, I get this error:但即使在我尝试运行它之前,我也会收到此错误:
my-app: sync failed我的应用程序:同步失败
Cause: https://downloads.gradle.org/distributions-snapshots/gradle-4.4-20171031235950+0000-all.zip原因: https : //downloads.gradle.org/distributions-snapshots/gradle-4.4-20171031235950+0000-all.zip
How do I fix this error?我该如何解决这个错误? Thanks in advance.提前致谢。
You can check and change the distribution url in the properties file $rootDir/gradle/wrapper/gradle-wrapper.properties
.您可以在属性文件$rootDir/gradle/wrapper/gradle-wrapper.properties
检查和更改分发 url。 See property distributionUrl
.请参阅属性distributionUrl
。
Value should be something as follows (update the gradle version depending on your Android Studio version)值应如下所示(根据您的 Android Studio 版本更新 gradle 版本)
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
You can fix it by the following steps: (currently using Android 3.6.3)您可以通过以下步骤进行修复:(目前使用的是Android 3.6.3)
This worked for me.这对我有用。
C:\\Users\\UserName.android
and rename the build-cache
folder to build-cache.bak
.转到C:\\Users\\UserName.android
并将build-cache
文件夹重命名为build-cache.bak
。C:\\Users\\UserName.AndroidStudio3.6\\system
and rename these folders:转到C:\\Users\\UserName.AndroidStudio3.6\\system
并重命名这些文件夹:
caches
to caches.bak
caches
到caches.bak
compiler
to compiler.bak
compiler
到compiler.bak
compile-server
to compile-server.bak
compile-server
到compile-server.bak
compile-server
compile-server.bak
conversion
to conversion.bak
conversion
为conversion.bak
external_build_system
to external_build_system.bak
external_build_system
到external_build_system.bak
frameworks
to frameworks.bak
frameworks
到frameworks.bak
gradle
to gradle.bak
gradle
到gradle.bak
resource_folder_cache
to resource_folder_cache.bak
resource_folder_cache
到resource_folder_cache.bak
If the folder is not in the Android3.6 folder, move to the next step.如果该文件夹不在 Android3.6 文件夹中,请转到下一步。
I've encountered a similar error when I tried importing the Sunshine project from the Udacity Android development course.我在尝试从 Udacity Android 开发课程导入 Sunshine 项目时遇到了类似的错误。 I fixed the issue by downloading the mentioned zip file and extracted it to the C:\\Users\\<username>\\.gradle\\native
folder.我通过下载提到的 zip 文件并将其解压缩到C:\\Users\\<username>\\.gradle\\native
文件夹解决了该问题。
Then in Gradle settings, use local Gradle distribution
and set the Gradle home
path to the downloaded gradle folder.然后在 Gradle 设置中,使用local Gradle distribution
并将Gradle home
路径设置为下载的 gradle 文件夹。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.