AS中加载gradle时出现Gradle sync failed: Could not find com.android.tools.build:gradle.的错误

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AS中加载gradle时出现Gradle sync failed: Could not find com.android.tools.build:gradle.的错误相关的知识,希望对你有一定的参考价值。

 

时间:2019/12/7

 

这次接着整理加载gradle时出现的错误

 

出现的错误:

1 Gradle sync failed: Could not find com.android.tools.build:gradle:3.5.0.  
2          Searched in the following locations:  
3          file:/F:/studio/studio2.0/gradle/m2repository/com/android/tools/build/gradle/2.8/gradle-2.8.pom  
4          file:/F:/studio/studio2.0/gradle/m2repository/com/android/tools/build/gradle/2.8/gradle-2.8.jar  
5          https://jcenter.bintray.com/com/android/tools/build/gradle/2.8/gradle-2.8.pom  
6          https://jcenter.bintray.com/com/android/tools/build/gradle/2.8/gradle-2.8.jar  
7          Required by:  
8          :TestApk:unspecified  
9          Consult IDE log for more details (Help | Show Log)

 

解决方法:

1.在bulid.gradle(project)文件的相应地方中添加google(),如下图(一共要在两个地方加):

 1 buildscript {
 2     repositories {
 3         //添加
 4         google()
 5         jcenter()
 6     }
 7     dependencies {
 8         classpath \'com.android.tools.build:gradle:3.1.1\'
 9 
10         // NOTE: Do not place your application dependencies here; they belong
11         // in the individual module build.gradle files
12     }
13 }
14 
15 allprojects {
16     repositories {
17      //添加
18         google()
19         jcenter()
20     }
21 }
22 
23 task clean(type: Delete) {
24     delete rootProject.buildDir
25 }

2.重新编译

 

参考博文:https://www.cnblogs.com/xiaoxiaoyibu/p/8830826.html

 

以上是关于AS中加载gradle时出现Gradle sync failed: Could not find com.android.tools.build:gradle.的错误的主要内容,如果未能解决你的问题,请参考以下文章

Gradle project sync failed

AS中导入eclipse项目时出现的问题

Actionscript 3 - 在我的 swf 中加载另一个 swf 时出现列表错误

Android Studio 首坑 Gradle sync failed: Cause: error in opening zip file 的错误

Gradle sync failed: Connection timed out: connect

使用 Gradle 在运行时出现 NoClassDefFoundError