Patrick Brennan
Patrick Brennan

Reputation: 2738

Android Studio Unsupported Version of Gradle Plugin

Similar to the question asked here : Android Studio unsupported version of gradle but I'm using a compatible version , but the answer there does not fix the problem for me.

I am using Android Studio Beta 0.8.1 running under Ubuntu 14.04 LTS. I am trying to import a project which is shared with my team, but when I clone the project and attempt to build it, I get this error:

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>

When I click the link, I get this error:

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.

Here is the relevant section of my build.gradle file:

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

I have manually installed a recent version of Gradle in an attempt to rectify this problem (Ubuntu really only wants to let me have version 1.4, but our project is configured for Gradle 1.11+. Here is the output of "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

I tried to set Android Studio to use the local Gradle installation (File > Settings > Gradle > Use local gradle distribution), but this only yields an error that a given task can't be found in the root project. (?)

When I build the project from the command line with the command "./gradlew clean assembleDebug", it builds perfectly and I am able to install and run the APK.

I don't understand what I'm doing wrong, or how to fix it. Any clues would be deeply appreciated!

Upvotes: 16

Views: 30136

Answers (3)

Xiao
Xiao

Reputation: 1582

I also got this error on Linux Mint 17.

I had installed gradle from the Ubuntu repositories but it was version 1.4. So I downloaded 1.10 using the ppa:

sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update
sudo apt-get install gradle-1.10

Note Don't do sudo apt-get install gradle, as the newest version (2.x at this time) is also rejected by Android Studio

Upvotes: 0

Patrick Brennan
Patrick Brennan

Reputation: 2738

Now I understand what I was doing wrong. The newer version of Andoid Studio which I have installed does not support the gradle 0.11.* plugin. The fix is to update all of my build.gradle files thus:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'
    }
}

So I have changed the 'gradle:0.11.+' to 'gradle:0.12.+'.

By opening the build.gradle file(s) and looking at the error messages which were displayed on the relevant lines, I could see that they were much more useful than the error messages which I was originally confronted with. I was looking for some way to upgrade my gradle installation, or my gradle plugin in Android Studio. What Android Studio wanted was for me to update the build file to specify a different gradle plugin version. I don't understand why that was really necessary - I haven't changed a thing in the source code! - but Android Studio will now happily build and run my project.

Thanks to Gabriele Mariotti for clarification.

Upvotes: 1

Gabriele Mariotti
Gabriele Mariotti

Reputation: 364730

Android Studio 0.8.1 requires the gradle-plugin 0.12.

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

Check this answer for compatibility:

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

Upvotes: 18

Related Questions