Android Studio 不支持的 Gradle 插件版本

标签 android android-studio gradle android-gradle-plugin build.gradle

与此处提出的问题类似:Android Studio unsupported version of gradle but I'm using a compatible version ,但那里的答案并不能解决我的问题。

我正在使用在 Ubuntu 14.04 LTS 下运行的 Android Studio Beta 0.8.1。我是 尝试导入与我的团队共享的项目,但是当我克隆 项目并尝试构建它,我收到此错误:

Error:The project is using an unsupported version of the Android Gradle
plug-in (0.11.2) <a href="fixGradleElements">Fix plug-in version and re-import
project</a>

当我点击链接时,我得到这个错误:

12:21:30 PM Quick Fix Failed
         Unable to find any references to the Android Gradle plug-in in build.gradle files.
         Please click the link to perform a textual search and then update the build files manually.

这是我的 build.gradle 文件的相关部分:

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

我手动安装了最新版本的 Gradle 以尝试纠正 这个问题(Ubuntu真的只想让我有1.4版本,但是我们的 项目配置为 Gradle 1.11+。这是“gradle -v”的输出:

------------------------------------------------------------
Gradle 1.11
------------------------------------------------------------

Build time:   2014-02-11 11:34:39 UTC
Build number: none
Revision:     a831fa866d46cbee94e61a09af15f9dd95987421

Groovy:       1.8.6
Ant:          Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy:          2.2.0
JVM:          1.8.0_05 (Oracle Corporation 25.5-b02)
OS:           Linux 3.13.0-30-generic amd64

我尝试将 Android Studio 设置为使用本地 Gradle 安装 (文件 > 设置 > Gradle > 使用本地 gradle 分发),但这只是 产生在根项目中找不到给定任务的错误。 (?)

当我从命令行使用命令“./gradlew”构建项目时 clean assembleDebug”,它构建完美,我能够安装和运行 APK。

我不明白我做错了什么,或者如何解决它。任何线索都是 非常感谢!

最佳答案

Android Studio 0.8.1 需要 gradle-plugin 0.12。

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

检查此答案的兼容性:

Android Studio Gradle issue upgrading to version 0.5.0 - Gradle Migrating From 0.8 to 0.9 - Also Android Studio upgrade to 0.8.1

关于Android Studio 不支持的 Gradle 插件版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24599785/

相关文章:

Android Studio TFS(团队基础服务器)

android - 应用程序如何检测到它将被卸载?

android - 使用 Urban Airship 库的 GCM 推送通知

android - 如何使用 3.x.x Gradle 插件在 Android Studio 中选择模块的风格

java - 在 gradle 和 Java13 中运行时 Liquibase XmlElement 错误异常

android - 位图 toString 并再次返回

android - 如何以编程方式禁用或隐藏系统设置?

java - 有没有办法准确检测 Android 中的 Activity 何时被销毁?

android - 无法解决:com.github.PhilJay.MPAndroidChart:v2.2.4

android - Android Studio-想要1 APK,但无法正常工作