赞
踩
Android Studio新建工程后编译Gradle错误,可能提示正在下载Gradle,但是一直会卡着,1小时之后还停留在原来的进度。
问题的原因,在于默认的Google网站问题,
1、建议使用国内的网址直接下载,例如:
https://mirrors.cloud.tencent.com/gradle/gradle-8.0-bin.zip
2、下载后的文件包,拷贝到Android Studio的对应目录下,类似于:
C:\Users\账号\.gradle\wrapper\dists\gradle-8.0-bin\ca5e32bp14vu59qr306oxotwh
3、回到Android Studio界面下,更改setting.gradle文件:
pluginManagement { repositories { maven { url 'https://maven.aliyun.com/repository/google' }//增加 maven { url 'https://maven.aliyun.com/repository/public' }//增加 google() mavenCentral() gradlePluginPortal() } } dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { maven { url 'https://maven.aliyun.com/repository/google' }//增加 maven { url 'https://maven.aliyun.com/repository/public' }//增加 google() mavenCentral() } } rootProject.name = "My Application" include ':app'
4、重新Reload Gradle Project
前面因为已经下载了Gradle,并放在了合适的目录下,所以这一步,就不用再下载gradle了,接下来的速度会很快,界面上出现类似如下的提示,就意味着Gradle的问题解决了。
Starting Gradle Daemon...
Gradle Daemon started in 3 s 769 ms
Download https://dl.google.com/dl/android/maven2/com/android/application/com.android.application.gradle.plugin/8.0.2/com.android.application.gradle.plugin-8.0.2.pom, took 378 ms (1.33 kB)
Download https://dl.google.com/dl/android/maven2/com/android/library/com.android.library.gradle.plugin/8.0.2/com.android.library.gradle.plugin-8.0.2.pom, took 228 ms (1.32 kB)
Download https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/8.0.2/gradle-8.0.2.pom, took 207 ms (11.35 kB)
Download https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/8.0.2/gradle-8.0.2.module, took 92 ms (13.17 kB)
......
5、hope you lucky!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。