【问题标题】:Could not find com.android.tools.build:gradle:5.6找不到 com.android.tools.build:gradle:5.6
【发布时间】:2019-12-27 15:21:27
【问题描述】:

我的 gradle 有问题,我尝试了许多在 stackoverflow 和其他文档上找到的解决方案,但仍然无法正常工作,请帮助我

【问题讨论】:

    标签: android android-studio gradle build.gradle


    【解决方案1】:

    不要将 gradle 与 Android Gradle 插件混淆。

    classpath 'com.android.tools.build:gradle:5.6'
    

    这是 Android Gradle 插件,5.6 不存在

    使用最新的稳定版本:

    classpath 'com.android.tools.build:gradle:3.5.0'
    

    Check the release notes 用于其他版本。

    要更改 gradle 版本, 编辑文件 gradle/wrapper/gradle-wrapper.properties

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

    official doc 中的更多信息。

    【讨论】:

      【解决方案2】:

      Gradle 插件版本目前没有 5.6 版。下面的链接列出了 Google Marvel 存储库中 Gradle 插件版本的所有最新版本。

      https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google

      我认为您的意思是您的 Gradle 包装器属性中的 distributionUrl 版本:

      转到您的 gradle-wrapper.properties 文件并按要求完成:

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

      那么您的项目的 build.gradle 文件将如下所示:

      // Top-level build file where you can add configuration options common to all sub-projects/modules.
      buildscript
              {
          repositories
                  {
              google()
              jcenter()
          }
      
          dependencies
                  {
              // NOTE: Do not place your application dependencies here; they belong
              // in the individual module build.gradle files
              classpath 'com.google.gms:google-services:4.2.0'
              classpath 'com.android.tools.build:gradle:3.4.2'
          }
      }
      
      
      allprojects {
      
          repositories {
              google()
              maven { url 'https://maven.google.com' }
              jcenter()
          }
      
      }
      
      task clean(type: Delete) {
          delete rootProject.buildDir
      }
      

      【讨论】:

        猜你喜欢
        • 2021-12-16
        • 2019-05-12
        • 2019-11-06
        • 2020-02-08
        • 2017-04-11
        • 2018-09-05
        • 2019-09-24
        • 2021-03-12
        • 2020-09-22
        相关资源
        最近更新 更多