AS报错:gradle project sync failed

时间:2022-04-14 23:28:27

情形一:

Android studio下突然报错:

gradle project sync failed.Basic functionality(e.g.editing,debugging) will not work properly.

解决方案:进入项目目录下,找到 gradle\wrapper\gradle-wrapper.properties 文件,记事本打开,内容如下:

Tue Jul 24 14:48:54 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

最后一句,https://services.gradle.org/distributions/gradle-4.4-all.zip

studio会下载上面的Gradle,不知道什么原因下载不下来,我们可以手动下载这个版本的Gradle,无需解压直接拷贝到

C:\Users\Administrator\.gradle\wrapper\dists\gradle-2.10-all\9br9xq1tocpiv8o6njlyu5op1下即可,重启studio,问题解决

情形二:

1.拷贝他人的项目,而二者的AS版本不一样,调整自己的SDK版本和SDK工具版本。

2.AS升级到3.2.1版本后提示:

Warning:The specified Android SDK Build Tools version (26.0.1) is ignored, as it is below the minimum
supported version (26.0.3) for Android Gradle Plugin 3.0.1. Android SDK Build Tools 26.0.3 will be used. To suppress this warning, remove "buildToolsVersion '26.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

解决方法:

AS报错:gradle project sync failed

AS报错:gradle project sync failed

框框处改成指定的版本。

接着,在build.gradle(Project)中修改Gradle版本到3.2.1或更新版本

如下图:

AS报错:gradle project sync failed

3.仍旧报错。根据所提示的文件找到Android目录下的该文件

AS报错:gradle project sync failed

对project下的chat/src/main/res/values-w820dp下的ids.xml修改
将:
<item type="id" name="about_version_code">false</item>
<item type="id" name="split">false</item>
修改成:
<item type="id" name="about_version_code"/>
<item type="id" name="split"/>
项目可以成功运行并安装使用!