253

As I've been using

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

In the build.gradle file, I got the following error since gradle version 2.10 has been released. The error is :

Warning:Gradle version 2.10 is required. Current version is 2.8. If using the gradle wrapper, try editing the distributionUrl in C:\Users\blahblah\myproject\gradle\wrapper\gradle-wrapper.properties to gradle-2.10-all.zip

at first it looks easy to solve by the guide, but when I'd done the change, I got the error again.

I'm using Android Studio 2.0 with the latest Android SDK Tools 24.4.1 and Android SDK Build Tools 23.0.2

I've even tried to download Gradle 2.10 and put it manually on android-studio\gradle\ folder, but no luck.

Any help would be appreciated.

SalmanShariati
  • 3,873
  • 4
  • 27
  • 46

28 Answers28

399

You need to change File > Settings > Builds,Execution,Deployment > Build Tools > Gradle >Gradle home path

On Mac OS, change the path in Android Studio > Preferences > Builds,Execution,Deployment > Build Tools > Gradle >Gradle home

Or set Use default gradle wrapper and edit Project\gradle\wrapper\gradle-wrapper.properties files field distributionUrl like this

distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
Tom Pace
  • 2,347
  • 1
  • 24
  • 32
adrbtk
  • 4,470
  • 1
  • 12
  • 11
  • 26
    Switching to "default" solved this for me also. The pointed to file in the error already was modified as suggested, so it was confusing! – mm2001 Jan 16 '16 at 01:17
  • 4
    and dont forget a 'gradle sync' after doing so. – kellogs Jan 20 '16 at 22:40
  • 21
    In mac the path is: Android Studio > Preferences > Builds,Execution,Deployment > Build Tools > Gradle – MorZa Jan 26 '16 at 11:29
  • 27
    This is not working for me. My gradle-wrapper.properties already has this line and I still get the error every time. – fobbymaster Feb 04 '16 at 23:28
  • 2
    Second option (setting default gradle wrapper AND editing gradle-wrapper.properties) worked for me. Please keep in mind that if you don't have gradle 2.10 installed on your computer, it might take some time to download and build (25 minutes on my computer). And, as kellogs said, you MUST sync again after that. – Mar Bar Feb 17 '16 at 19:45
  • 1
    This is a good useful anwer. However downloading the zip, and extracting the files onto a directory was necessary for me. – The Original Android Mar 14 '16 at 02:56
  • how can you set it to default? I'm using Android Studio thanks. I don't have any options from my project-level settings. – Kairi San Mar 31 '16 at 03:13
  • @MorZa your comment really ought to be edited right into the text of the answer. On the mac, I did almost exactly what the answer said, File > [Other] Settings > Default Settings > Builds,Execution,Deployment > Build Tools > Gradle .. and then went searching in the Service directory path... almost lost extra time there. Thanks for the comment – Tom Pace Apr 12 '16 at 18:26
  • @MarBar doing both as you said, setting Default wrapper and editing still failed for me. Updating the distributionURL does nothing, so I wonder if something else is overriding, methinks I must quit Android Studio. I've never used gradle before this project (hired into gradle project), but I'm attempting to set all the configurations to make sense and be clean, but it's really still feeling like Eclipse. – Tom Pace Apr 12 '16 at 18:47
  • 34
    Can't the Android Studio team provide a bug-less update for once?? Jesus!! – Josh Apr 18 '16 at 12:25
  • My project is already set to use the default Gradle wrapper, and the distributionUrl is already set as specified, and I'm still getting this error. – Kevin Krumwiede Aug 06 '16 at 06:37
  • I have tried this in 100 different ways and the error always repeats. This is now Android 2.2.1 and I get Error:Gradle version 1.10 is required. Current version is 2.14.1. If using the gradle wrapper, try editing the distributionUrl in E:\projects\joxpAndroid\Health@Home\gradle\wrapper\gradle-wrapper.properties to gradle-1.10-all.zip. Please fix the project's Gradle settings. Migrate to Gradle wrapper and sync project and no matter what one does, the gradle-1.10 always comes up. I have no idea where Android Studio is getting that from. – Brian Reinhold Nov 08 '16 at 22:03
  • `distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip` works for me. – lordmegamax Nov 23 '16 at 15:48
86

Open Preference and search for Gradle or Navigate to Builds, Execution, Deployment > Build Tools > Gradle

Then change Project-Level setting to Use default gradle wrapper (recommended)

Or keep local gradle distribution option and set Gradle home to /.../gradle-2.10

Preference screen - Gradle

Make Sure that Gradle version is already setup to 2.10 in Module Settings

On the Project Window, right click on your project then select Open Module Settings (+)

Open Module Settings Project > Gradle version and enter 2.10

Update

Gradle Version: 3.3 Android Plugin version: 2.3.1

M'hamed
  • 2,508
  • 3
  • 24
  • 41
52

An easier way to accomplish this is to go to: Open Module Settings (your project) > Project > Gradle version and enter 2.10

cmota
  • 914
  • 6
  • 7
  • 3
    Changing the path didn't work because I didn't have gradle 2.10 (accepted answer) but this did – ono Jan 22 '16 at 00:06
  • I don't have Gradle version field to set. Does anybody know where is it in IntelliJ 2016? – Kimi Chiu Jul 09 '16 at 04:47
  • This is on Android Studio (although the IDE's are quite similar). On Project Structure you can just enter the version number you want - for example, 2.10. – cmota Jul 11 '16 at 13:20
41

Download the latest gradle-3.0-all.zip from

http://gradle.org/gradle-download/

download from Complete Distribution link

open in android studio file ->settings ->gradle

open the path and paste the downloaded zip folder gradle-3.0 in that folder

change your gradle 2.8 to gradle 3.0 in file ->settings ->gradle

Or you can change your gradle wrapper in the project

edit YourProject\gradle\wrapper\gradle-wrapper.properties file and edit the field distributionUrl in to

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

Jackson Chengalai
  • 3,907
  • 1
  • 24
  • 39
  • 1
    Android studio can sometimes be slow at downloading those files. You saved me the pain of waiting. Thanks – Phillip Kigenyi Jan 23 '16 at 10:02
  • 1
    There is no Settings item in the File menu of Android Studio. There are: |Other Settings > | Default Settings… | | Default Project Structure… |-------------- |Import Settings… |Export Settings… Which one do you mean? – informatimago Mar 01 '16 at 23:01
  • if you are using mac then it will be preferences->gradle – Jackson Chengalai Mar 02 '16 at 04:28
  • Besides the useful posted answers and the one voted as best answer, this step of downloading the zip and extracting the files onto a directory was necessary for me. – The Original Android Mar 14 '16 at 02:55
  • my Android Studio not even allowed me to choose the default gradle wrapper (it was dimmed/disabled) in the Settings under Menu. I need to download and extract the zip file to \gradle directory, and pointed to that directory. – early Mar 21 '16 at 16:06
  • Jackson Chengalai - there is no preferences->gradle on mac version - any other suggestions for making this change on OSX? – Tudor Apr 06 '16 at 08:59
  • Works fine adding distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip in gradle-wrapper.properties and sync project again, is not necesary modify gradle path in android studio. – e-info128 Apr 07 '16 at 18:11
15

For people who are using Ionic/Cordova framework, we need to change the distributionUrl in GradleBuilder.js file to var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'http\\://services.gradle.org/distributions/gradle-2.10-all.zip';

The GradleBuilder.js locates at project/platforms/android/cordova/lib/builders/GradleBuilder.js

nigong
  • 1,727
  • 3
  • 19
  • 33
11

First Check your Project-level settings at

File > Settings > Build, Executions, Deployment > Build Tools > Gradle

and Select the Option :

  • Use default gradle wrapper (recommended)

then go to Project's

Gradle > wrapper > gradle-wrapper.properties

and edit version of the distributionUrl

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

And you are done :)

Ashish Shukla
  • 1,027
  • 16
  • 36
10

For Android studio v2.1

Follow these easy steps from images.

  1. Go "File" and click "Project structure".Opening project structure settings for the project

  2. Then select "Project" from left menu and then change "Gradle version" to the version your sdk manager has installed. In my case it is 2.10 so i change version to 2.10 and then click on "Ok". And then android studio automatically do gradle sync again and error was fixed.Changing gradle version to the latest installed version for the project

Amit Tumkur
  • 2,752
  • 26
  • 27
8

Easiest way for me to fix this issue:

  1. close IDE.
  2. delete "gradle" folder
  3. re-open project.
android developer
  • 114,585
  • 152
  • 739
  • 1,270
3

The Android build system uses the Android Plugin for Gradle to support building Android applications with the Gradle build toolkit. The plugin runs independent of Android Studio so the plugin and the Gradle build system can be updated independently of Android Studio.

Use gradle wrapper (recommended) - select this option to use Gradle wrapper. Using Gradle wrapper lets you get automatic Gradle download for the build. It also lets you build with the precise Gradle version.

Newer versions of the Gradle plugin may require newer versions of Studio to enable the new features in the IDE, but the project should open in older versions of Studio, and build from there (since Gradle does the build). We will be very careful about this.

Click on Settings -> Build -> Execution -> Deployment ->
Gradle -> Select  default gradle wrapper

You can use

classpath 'com.android.tools.build:gradle:2.0.0-alpha3'  // or alpha2
Or //classpath 'com.android.tools.build:gradle:2.1.3'
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
3

I encountered the same issue before.

In the end, the problem is that you use terminal; it uses system config.

check it, whether you have set

"GRADLE_HOME=.\gradle-2.10" 

Hope it helps

J. Chomel
  • 8,193
  • 15
  • 41
  • 69
3

For those who uses ionic, go to
[project name]/platforms/android/cordova/lib/builders/GradleBuilder.js

on line 164 you will see the following:
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'http\\://services.gradle.org/distributions/gradle-2.13-all.zip';

This line is used to create your gradle-wrapper.properties, so any changes to the gradle-wrapper.properties wont matter. All you need to do is change the url to the latest version, sync the gradle and the problem is solved.

Just want to change the gradle version in the Android studio, go to File>settings>project and change the gradle version. After you apply, it will sync the project and you are ready to build.

Sphinx
  • 956
  • 7
  • 21
roger
  • 1,225
  • 2
  • 17
  • 33
3

If the problem persist, add the following code in the build.gradle of the top project.

buildscript {
System.properties['com.android.build.gradle.overrideVersionCheck'] = 'true'

...
}
saintjab
  • 1,626
  • 20
  • 31
3

Important:

If you are getting this when you run:
gradle build
from command line you have to use:
gradlew build
instead so that you will use gradle wrapper to downloaded the appropriate gradle version needed by the app.

When you execute gradle build you are using the global gradle installed on your system.

dsharew
  • 10,377
  • 6
  • 49
  • 75
2

Go to File -> Settings -> Build, Execution, Deployment -> Gradle -> choose Use default gradle wrapper

Lenny
  • 887
  • 1
  • 11
  • 32
2

for me all previous solutions failed, so i just edited

Project\gradle\wrapper\gradle-wrapper.properties -> field distributionUrl 
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip

to

distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Fasiha
  • 488
  • 3
  • 11
1

You need to change Prefrences > Builds,Execution,Deployment > Build Tools > Gradle >Gradle home path

Or set Use default gradle wrapper and edit Project\gradle\wrapper\gradle-wrapper.properties files field distributionUrl like this

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

Jaspreet Chhabra
  • 1,431
  • 15
  • 23
1

My problem maybe is different,so I just wanna tell somebody who may have the same problem as me.

I solved this problem by change Terminal path. when I run gradle clean, the error come cross "Gradle version 2.10 is required. Current version is 2.2.1".

I checked .gradle directory in my project, there are two versions in it: 2.2.1, 2.10.

when I run gradle -v, it shows my current version is 2.2.1. I change my system environment GRADLE_HOME to 2.10 root directory, then I restart terminal in AS and run 'gradle -v', it still shows the current verision is 2.2.1.

open setting -> terminal change the cmd.exe path to the System32/cmd.exe. then restart terminal, run gradle clean,everything is fine.

Freddy
  • 764
  • 2
  • 6
  • 21
1

I had Android Studio version 1.5.1 installed and was running into this error. I have the following buildscript (which was working on Ubuntu but not Windows):

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

I tried:

  1. gradlew clean
  2. Use default gradle wrapper (recommended)
  3. Use local distribution and linked to downloaded gradle 2.2.1 binary

None of these solutions worked unfortunately. It should be worth noting that upgrading Android Studio from 1.5.1 to 2.1.1 also failed with errors about 2.10 missing so could not be performed.

Solution: What I ended up doing was simply downloaded the latest stable version of Android Studio and installing that instead (2.1.1 at the time). After doing that gradle synced succesfully

alexgophermix
  • 4,189
  • 5
  • 32
  • 59
1

What worked for me on Mint 17.03 which is base off Ubuntu 14.04

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

Reopen Android Studio. Go to Run/Debug Configuration and there should be an icon saying you need to Update gradle. Just click it.

CESCO
  • 7,305
  • 8
  • 51
  • 83
1

I had the same problem and no answer in stackoverflow helped. But I found the issue in my project. It was because my .gitignore file contained these lines:

# Package Files #
*.jar
*.war
*.ear

and that is why git did not upload the MyProject\gradle\wrapper\gradle-wrapper.jar file to remote. So, I added this line to .gitignore:

!/gradle/wrapper/gradle-wrapper.jar

Make sure you had this line too. At least this solved my problem

Amiraslan
  • 794
  • 1
  • 8
  • 19
0

In Terminal type gradlew clean. it will automatically download and install gradle version 2.10(ie latest gradle verson available)

Eg : C:\android\workspace\projectname>gradlew clean

0

this work for me.

create a new project in android studio. Open project setting and copy the local gradle path. now open the project having gradle problem and paste that url and select local path.

click apply problem will get solved.

0

Some cases it does not work-out because there is no problem in your project gradle or android-studio.

Step 1:

Minimum supported Gradle version is 2.14.1. Current version is 2.11. If using the gradle wrapper, try editing the distributionUrl

  • Check gradle version in your system gradle -version
  • Older version upgrade gradle version brew install gradle

Step 2

  • Go to android-studio-> Preference-> Build,Execution,Deployment-> Gradle

  • Use default gradle wrapper and un-mark offline work

Step 3

  • Check distributionUrl in gradle-wrapper.properties

  • Upgrade if older version.

  • Clean Project

Prashant Srivastav
  • 1,723
  • 17
  • 28
0

I had to upgrade my version of Cordova to support the latest version of Gradle. Updating the distributionUrl in GradleBuilder.js didn't work for me.

Steve W
  • 1,062
  • 1
  • 9
  • 24
0

if your has this error that "supported Gradle version is 2.14.1. Current version is 2.4. ", on terminal. means your should update your gradle.

On Mac OS: you can use brew upgrade gradle

lingyfh
  • 1,363
  • 18
  • 23
0

In my case the problem was indeed in the distributionURL in gradle-wrapper.properties file and Android Studio auto-fixed inserting

distributionUrl=https://services.gradle.org/distributions/gradle-4.0-20170417000025+0000-all.zip

But this was a wrong URL. The correct one is

distributionUrl=https://services.gradle.org/distributions-snapshots/gradle-4.0-20170417000025+0000-all.zip

Apparently the url changed in gradle's API but not in Android Studio so fixing it by hand solved the problem for me.

0

Latest gradle

Download the latest gradle-3.3-all.zip from

http://gradle.org/gradle-download/

1.download from Complete Distribution link

2.open in android studio file ->settings ->gradle

3.open the path and paste the downloaded zip folder gradle-3.3 in that folder

4.change your gradle 2.8 to gradle 3.3 in file ->settings ->gradle

5.Or you can change your gradle wrapper in the project

6.edit YourProject\gradle\wrapper\gradle-wrapper.properties file and edit the field distributionUrl in to

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

shown in android studio's gradle files

-1

File - setting - Build Execution Deployment - Gradle - Select 'Use default gradle wrapper(recommended)'

Sanket Parchande
  • 894
  • 9
  • 14