【问题标题】:Android Studio Gradle version - Gradle version 2.8 is requiredAndroid Studio Gradle 版本 - 需要 Gradle 版本 2.8
【发布时间】:2016-04-08 22:08:30
【问题描述】:

我正在尝试构建一个 Android 项目,但出现以下错误

Error:(10, 1) A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
   > Gradle version 2.8 is required. Current version is 2.4. If using the gradle wrapper, try editing the distributionUrl in C:\Users\...\gradle\wrapper\gradle-wrapper.properties to gradle-2.8-all.zip

Gradle 版本似乎有问题,但是我检查了gradle-wrapper-property,它已经是 2.10。

同样在File-Project Structure-Project中,gradle-version也是2.10

不知道是怎么回事,我也重启过android-studio很多次了。

【问题讨论】:

  • 如果从命令行开始构建会发生什么?
  • 这个问题解决了吗?我没有看到您将任何答案标记为已解决
  • 确保 android studio 使用的是 wrapper gradle 而不是 android studio one 中的构建,preferences->gradle->check "use gradle wrapper"

标签: android android-studio gradle android-gradle-plugin gradlew


【解决方案1】:

转到 Android 首选项,只需将项目级别设置更改为使用默认 gradle 包装器(推荐)。

【讨论】:

    【解决方案2】:

    对于那些仍然需要帮助的人,另一个帖子上的答案为我做了link。

    您需要更改 Settings > Builds,Execution,Deployment > Build Tools > Gradle >Gradle home path

    或设置使用默认 gradle 包装器并像这样编辑Project\gradle\wrapper\gradle-wrapper.properties 文件字段distributionUrl

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

    【讨论】:

    • 更改“设置 > 构建、执行、部署 > 构建工具 > Gradle >Gradle”工作。我尝试更改“gradle-wrapper.properties”,然后执行 File -> Invalidate Caches/Restart -> Invalidate and Restart,但问题仍然存在。
    【解决方案3】:

    将 android studio 的版本从 1.4 更新到 1.5.1 为我解决了这个问题。

    【讨论】:

      【解决方案4】:

      在较旧的 android 插件中版本检查存在错误。要解决此问题,您可以返回 gradle 2.9 或使用更新的插件

      buildscript {
          dependencies {
              classpath 'com.android.tools.build:gradle:1.5.0'
          }
      }
      

      但我从您的错误消息中看到它尝试使用 gradle 2.4 运行,所以这可能是另一个问题。

      【讨论】:

      • 我试图改成这个,但它说找不到 gradle:1.5.0 然后我尝试将 android-studio 从 1.4 更新到 1.5.1。成功了
      【解决方案5】:

      我不认为将 Gradle 工具更改为 1.5.0 版本是必要的,但如果您使用的是 2.0-snapshot 或 beta 版本的 gradle,我建议您将其更改为 1.5.0。

      这个错误:

      Error:(10, 1) A problem occurred evaluating project ':app'.
      > Failed to apply plugin [id 'com.android.application']
         > Gradle version 2.8 is required. Current version is 2.4. If using the gradle wrapper, try editing the distributionUrl in
      

      C:\Users...\gradle\wrapper\gradle-wrapper.properties 到 gradle-2.8-all.zip

      仅告诉您项目的 Gradle 系统有点过时,需要更新到较新的版本。

      打开您的项目Android Studio 并在左侧导航器中找到名为gradle-wrapper.properties 的文件。它应该有这样的内容:

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

      用distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip 更改最后一行

      它应该可以工作。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-05-11
        • 1970-01-01
        • 2018-11-03
        • 1970-01-01
        • 2014-06-24
        • 1970-01-01
        • 2015-11-21
        • 2014-08-08
        相关资源
        最近更新 更多