找不到com.android.tools.build:gradle:3.0.1 [英] Could not find com.android.tools.build:gradle:3.0.1

查看:128
本文介绍了找不到com.android.tools.build:gradle:3.0.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用gradle包装器构建项目时,出现此错误:

When I try to build my project with gradle wrapper I get this error:

./gradlew

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all files for configuration ':app:classpath'.
   > Could not find com.android.tools.build:gradle:3.0.1.
     Searched in the following locations:
         https://maven.fabric.io/public/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
         https://maven.fabric.io/public/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
         https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
         https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
     Required by:
         project :app

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

同一项目在Android Studio中构建正常.

The same project builds OK in Android Studio.

我已经检查过这个这个,但是我m使用gradle wrapper版本4.1,添加了google()存储库,甚至尝试设置android.enableAapt2=false.还有其他提示吗?谢谢.

I've already checked this and this but I'm using gradle wrapper version 4.1, have added google() repository and even tried setting android.enableAapt2=false. Any other tips? Thanks.

我的根build.gradle文件:

 // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        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
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我的gradle-wrapper.properties文件:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

更新:Gabriele是对的.我还要在app/build.gradle file中添加存储库:

UPDATE: Gabriele was right. I'd to add the repository also in the app/build.gradle file:

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

我想我对这种说法感到困惑.要将这些库之一添加到您的构建中,请在您的顶级build.gradle文件中包含Google的Maven存储库" https://developer.android.com/studio/build/dependencies.html"rel =" noreferrer>此处.

I guess that I was confused with this stament "To add one of these libraries to your build, include Google's Maven repository in your top-level build.gradle file" in here.

推荐答案

只想留下一个额外的提示.安装Android Studio时,我读到某处建议保留此配置(带有'+'符号)

just wanted to leave an extra tip. When I installed Android Studio, I read somewhere that it was recommended to leave this configuration (with the '+' symbol)

build.gradle(项目)

dependencies {
        classpath 'com.android.tools.build:gradle:+'
        .....
        #more lines here
}

但是,我正在使用的项目使用的是gradle的旧版本,并且此行始终要求使用最新版本.花了我一段时间才弄清楚.

However, the project I am using uses an old version of gradle, and this line always requested the latest version. Took me a while to figure it out.

这篇关于找不到com.android.tools.build:gradle:3.0.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆