1. 程式人生 > >Could not find com.android.tools.build:gradle:3.0.1

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

更新gradle後執行應用,報錯。
解決辦法:
這裡寫圖片描述

提示找不到gradle:3.0.1
在頂層build.gradle 中,可以看到build.gradle的配置:

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

        // NOTE: Do not place your application dependencies here; they belong
        // in
the individual module build.gradle files } } ...

需要做的修改:新增maven倉庫,即在repositories中新增

maven {
            url 'https://maven.google.com'
        }

修改後

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }

這裡可以對比一下2.2.3的配置

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

        // NOTE: Do not place your application dependencies here; they belong
        // in
the individual module build.gradle files } } ...