28

After upgrade message states:

Failed to refresh Gradle project 'XXX'
The project is using an unsupported version of the Android Gradle plug-in (0.8.3).
Version 0.9.0 introduced incompatible changes in the build language.
Please read the migration guide to learn how to update your project.

Same kind of issue after upgrade to Android Studio to version >= 0.8.0

indivisible
  • 4,892
  • 4
  • 31
  • 50
Cedric Simon
  • 4,571
  • 4
  • 40
  • 52

8 Answers8

61

Android Studio 0.5.0 requires gradle-plugin 0.9.0

The gradle-plugin 0.9.0 works with Gradle 1.10 or Gradle 1.11

Modify your build.gradle script as suggested by Cedric.

There is a relation between gradle-plugin and the gradle version. For example

UPDATED TO 27/11/2015:

com.android.tools.build:gradle:0.6.+   -> gradle 1.8
com.android.tools.build:gradle:0.7.+   -> gradle 1.9
com.android.tools.build:gradle:0.8.+   -> gradle 1.9/1.10
com.android.tools.build:gradle:0.9.+   -> gradle 1.10/1.11
com.android.tools.build:gradle:0.10.+  -> gradle 1.10/1.11/1.12
com.android.tools.build:gradle:0.11.+  -> gradle 1.10/1.11/1.12
com.android.tools.build:gradle:0.12.+  -> gradle 1.10/1.11/1.12
com.android.tools.build:gradle:0.13.+  -> gradle 2.1
com.android.tools.build:gradle:0.14.+  -> gradle 2.1
com.android.tools.build:gradle:1.0.+   -> gradle 2.2.1-2.3
com.android.tools.build:gradle:1.1.+   -> gradle 2.2.1-2.3
com.android.tools.build:gradle:1.2.+   -> gradle 2.2.1+
com.android.tools.build:gradle:1.3.+   -> gradle 2.2.1+
com.android.tools.build:gradle:1.3.+   -> gradle 2.2.1+
com.android.tools.build:gradle:1.5.+   -> gradle 2.2.1+
com.android.tools.build:gradle:2.0.+   -> gradle 2.10.0+

You can find gradle version used in your project in the file gradle/wrapper/gradle-wrapper.properties

Also there is a relation between gradle-plugin and the IDE version.

Android Studio 0.3.x  -> gradle-plugin 0.6
Android Studio 0.4.x  -> gradle-plugin 0.7
Android Studio 0.4.3+ -> gradle-plugin 0.8
Android Studio 0.5.x  -> gradle-plugin 0.9
Android Studio 0.5.8  -> gradle-plugin 0.9.+ or 0.10.+
Android Studio 0.5.9  -> gradle-plugin 0.9.+ or 0.10.4+
Android Studio 0.6.x  -> gradle-plugin 0.11.+
Android Studio 0.8.x  -> gradle-plugin 0.12.+
Android Studio 0.8.11+  -> gradle-plugin 0.13.+ / gradle-plugin 0.12.+
Android Studio 0.9.x  -> gradle-plugin 0.14.+
Android Studio 1.0.0  -> gradle-plugin 1.0.0
Android Studio 1.1.x  -> gradle-plugin 1.0.0/ 1.1.x / 1.2.x
Android Studio 1.2.x  -> gradle-plugin 1.0.0/ 1.1.x / 1.2.x
Android Studio 1.3.x  -> gradle-plugin 1.0.0/ 1.1.x / 1.2.x / 1.3.x 
Android Studio 1.4.x  -> gradle-plugin 1.0.0/ 1.1.x / 1.2.x / 1.3.x 
Android Studio 1.5.x  -> gradle-plugin 1.0.0/ 1.1.x / 1.2.x / 1.3.x / 1.5.x
Android Studio 2.0.x  -> gradle-plugin 2.0.0

 Also gradle 1.12 requires Android Studio 0.5.8+

For updated news you can check this link: http://tools.android.com/recent
For updated doc about the gradle plugin check here.

If you change your plugin version, check compatibility, and then click sync project with your gradle files.It will download a new plugin version if you need it.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • 6
    Thanks for listing these relationships! I've been searching and am really surprised I haven't been able to find this info concisely presented on http://www.gradle.org/ or http://developer.android.com/. Considering the multitude of questions we see regarding missmatching of these versions I'm surprised this info is not front and center on one of these sites! – Sound Conception Mar 13 '14 at 08:53
  • Thanks for explaining mate, but im having a problem with gradle 2.0. I use 0.12.+ but keep getting error sying " Please use version 1.10." Cant find why its asking for 1.10! – Nabdreas Jul 04 '14 at 09:59
  • @Kangars 0.12 doesn't support gradle 2.0 in my experience. – Gabriele Mariotti Jul 04 '14 at 10:29
  • Gabriele Marriotti Thats possibly why its been complaining about it. I raised a question but seems like it is the case! http://stackoverflow.com/questions/24289410/gradle-version-1-10-is-required-current-version-is-2-0 – Nabdreas Jul 04 '14 at 11:10
  • Thanks this was super helpful, I am on the latest studio and version and using this in my gradle wrapper: distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip – mattdlockyer Jul 24 '14 at 19:26
  • Thanks this helped me get the project files in onder after upgrading AS. I use AS 0.8.9 so i updated my project to use `gradle-plugin 0.12.2` in `build.gradle` and therefor `gradle 1.12` in `gradle-wrapper.properties`. ... After every Android Studio upgrade i have to wrestle with Gradle when opening older projects, this not being prominently documented i dont understand. – Barry Staes Oct 02 '14 at 07:24
42

To fix it, open file called build.gradle in the project root, and change gradle version there to 0.9.+.

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

To be repeated for each project ;(

If you then get a message like "Unable to load class 'org.gradle.api.artifacts.result.ResolvedComponentResult".

Go to you project_folder/gradle/wrapper directory and edit Unable to load class 'org.gradle.api.artifacts.result.ResolvedComponentResult'. file changing the distributionUrl to

distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip

After upgrade to version 0.8.1 (full download and copy SDK folder over), had to have new version of gradle installed by IDE (using the "Fix it" link a couple of time :S ), and modifing the "android" section of the gradle file in project folder from 19.0 to 19.1, as below: buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.12.+' } } apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion '19.1.0'

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 19
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:19.1.+'
    compile 'com.android.support:support-v4:19.1.0'
}
Cedric Simon
  • 4,571
  • 4
  • 40
  • 52
  • worked great. I only had to change the distributionURL – Hackmodford Mar 07 '14 at 15:37
  • Oddly enough, changing `classpath` from `com.android.tools.build:gradle:0.9.+` to `com.android.tools.build:gradle:0.9.0` fixed the Gradle sync for me. Not sure why, or if it was coincidence. – theblang Mar 07 '14 at 22:03
  • close your project and re import the same project it fix automatically by android studio 0.5.1 – codercat Mar 19 '14 at 07:49
4

I had the same error, but already had

classpath 'com.android.tools.build:gradle:0.9.+'

set like this, as Cedric Simon suggested. Thanks to the comment of mattblang, I tried to change it to 0.9.0 and refreshed it

for those who don't know, where the refresh button is, look below:

enter image description here

Afterwards I tried what happens when I change it back to 0.9.+ and refresh again...and it still works.

So I assume, only pressing the refresh button would have sufficed.

Junior Mayhé
  • 16,144
  • 26
  • 115
  • 161
lucidbrot
  • 5,378
  • 3
  • 39
  • 68
2

I faced Same problem Migrating into gradle version 1.0.0.. This solution helps me and save the date..

Update Plugin and Gradle Version Numbers

The Android Gradle plugin version is typically listed in the top level build.gradle file in the project, and can be updated as follows:

Let me consider i have version 0.8.. show my build.gradle(project root folder/build.gradle) shows

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

remove the old version(0.8) and add new version 1.0.0 like this

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

And also change the gradle/wrapper/gradle-wrapper.properties:

remove the old distributionUrl and add new url

distributionUrl=http://services.gradle.org/distributions/gradle-2.2.1-all.zip

and change the runProguard in project root/app/build.gradle

BEFORE:

buildTypes { release { runProguard true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }

AFTER:

buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }

For more information : Migrating gradle Project(click here)

AnanThDev
  • 337
  • 2
  • 16
0

The most simple Android project has the following build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }

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

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.0"
}

There are 3 main areas to this Android build file:

new-build-system user-guide

codercat
  • 22,873
  • 9
  • 61
  • 85
0

When I updated to Android Studio 1.0 I found that I need to update to use 1.0.0 version of gradle.

I had

  dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0-rc2'

I changed it to remove the "-rc2"

  dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
Brian S
  • 3,096
  • 37
  • 55
0

Android Studio version 1.0.2 The idea of tight coupling between IDE version and build version is bad.

Android Studio 1.0.2. Gralde plugin 1.0.+ gradle.properties, distribution URL=http://services.gradle.org/distributions/gradle-2.2.1-bin.zip

user827096
  • 565
  • 1
  • 6
  • 11
-1

hmm I'm getting this error when I try to add this dependency.

Error:(22) A problem occurred evaluating project ':app'.

Could not find method classpath() for arguments [com.android.tools.build:gradle:0.9.+] on project ':app'.

Ok solved it. This line should be part of the build.gradle "in the project root" as stated above, but I did not recognize. Updating the Build tools to 19.03 actually inserted it in automatically.