欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

AndroidStudio 报错:Could not find com.android.tools.build:gradle

程序员文章站 2022-05-09 20:38:09
【AndroidStudio 报错:Could not find com.android.tools.build:gradle】 报错 Error: Could not f...

AndroidStudio 报错:Could not find com.android.tools.build:gradle】

报错

Error: Could not find com.android.tools.build:gradle:2.2.1. 
Searched in the following locations: 
file:/D:/software/android/android-studio-ide-145.3276617-windows/android-studio/gradle/m2repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom 
file:/D:/software/android/android-studio-ide-145.3276617-windows/android-studio/gradle/m2repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar 
https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom 
https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar

解决方法:进入%android-studio安装目录%\gradle\m2repository\com\android\tools\build\gradle
AndroidStudio 报错:Could not find com.android.tools.build:gradle

将项目中的build.gradle文件中

dependencies {
        classpath 'com.android.tools.build:gradle:2.2.1'
}

改为

dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'
}

即可。

注意:gradle的版本指的是仓库中的gradle编译工具版本,不是gradle版本。

AndroidStudio 报错:Could not find com.android.tools.build:gradle

再补充一点

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the inpidual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
    }
}

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.3'
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}
dependencies {
}

android { buildToolsVersion ‘23.0.3’ }

这个是在sdk的build-tools目录下

AndroidStudio 报错:Could not find com.android.tools.build:gradle