0

我刚刚更新了我的 android studio preview 3.0 canary 3。在此之后我尝试运行该项目但显示以下错误。

Error:Could not find com.android.tools.build:gradle:3.0.0.
Searched in the following locations:
    file:/opt/android-studio-preview/gradle/m2repository/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom
    file:/opt/android-studio-preview/gradle/m2repository/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.jar
    https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom
    https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.jar
Required by:
    project :
4

2 回答 2

6

您需要做的主要事情是:

将您的项目级别build.gradle文件更改为:

buildscript {
    repositories {
        ...
        // You need to add the following repository to download the
        // new plugin.
        maven {
          url 'https://maven.google.com'
        }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
    }
}

将您的 gradle-wrapper.properties 更改distributionUrl为当前最新可用的 Gradle 版本。

distributionUrl=https://services.gradle.org/distributions/gradle-4.0-rc-1-all.zip

完成此步骤后,您的项目还无法编译,您需要按照此处有关如何将应用程序转换build.gradle为新插件的所有说明进行操作

于 2017-06-05T08:36:09.083 回答
0

根据更新更改您build.gradle (project_name)的一行( ):-classpath

dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0-alpha3'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
于 2017-06-05T08:47:02.663 回答