Could not find com.android.tools.build:gradle:3.3

1. 问题描述:

android studio中,新导入一个android项目,编译错误如下:


Error:Could not find com.android.tools.build:gradle:3.3.
Searched in the following locations:
    file:/D:/as231/gradle/m2repository/com/android/tools/build/gradle/3.3/gradle-3.3.pom
    file:/D:/as231/gradle/m2repository/com/android/tools/build/gradle/3.3/gradle-3.3.jar
    https://repo1.maven.org/maven2/com/android/tools/build/gradle/3.3/gradle-3.3.pom
    https://repo1.maven.org/maven2/com/android/tools/build/gradle/3.3/gradle-3.3.jar
Required by:
    project :


2. 分析与解决:

很显然,是gradle版本没有找到。查看本地目录,的确没有“D:/as231/gradle/m2repository/com/android/tools/build/gradle/3.3/”。

只有一个2.3.1的目录。于是,将build.gradle中相关的classpath改为2.3.1,问题解决。如下图:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1'
    }
}

你可能感兴趣的:(android-gradle)