【问题标题】:Could not find com.android.tools.build:gradle:4.1.1找不到 com.android.tools.build:gradle:4.1.1
【发布时间】:2021-03-12 22:48:24
【问题描述】:

当我运行一个项目时,我得到了错误:

找不到 com.android.tools.build:gradle:4.1.1。 在以下位置搜索:

我的 gradle 文件如下所示:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
    classpath "com.android.tools.build:gradle:4.1.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
}

我现在能做什么?

【问题讨论】:

    标签: android gradle


    【解决方案1】:

    如果您在伊朗、中国等地...从 android 文件夹中删除 .gradle 文件夹,然后使用 VPN 重试。

    【讨论】:

      【解决方案2】:

      转到build.gradle 中的gradle-wrapper.properties 文件,您将看到指定distributionUrl 的最后一行。将 distributionUrl 替换为以下一个。

      distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
      

      让下载完成,您的问题将得到解决。如果您想避免下载,请将 com.android.tools.build:gradle:4.1.1 的版本降低到 4.0.0+ 或 3.0.0+

      【讨论】:

        【解决方案3】:

        这里的问题是你要使用的android工具插件已经移动了。旧发行版位于 jcenter,而新发行版位于“https://maven.google.com”

        更新您的存储库以包含“https://maven.google.com”

        allprojects {
            repositories {
                google()
                jcenter()
                maven { url "https://maven.google.com" }
            }
        }
        

        【讨论】:

          【解决方案4】:

          类路径'com.google.gms:google-services:3.0.0'

          请在上面的依赖项下添加

          【讨论】:

            猜你喜欢
            • 2021-03-30
            • 1970-01-01
            • 2021-05-14
            • 2021-12-16
            • 2019-05-12
            • 2019-11-06
            • 2019-12-27
            • 2020-02-08
            • 2017-04-11
            相关资源
            最近更新 更多