434

I installed Android Studio 0.1.9. Today I got and update to version 0.2 and of course I updated. After the installation I restarted Android Studio but now I get this message:

Project is using an old version of the Android Gradle plug-in. The minimum supported version is 0.5.0. Please update the version of the dependency 'com.android.tools.build:gradle'

How do I do that? I can't find any update tools for the gradle plugin in android studio.

Liam
  • 27,717
  • 28
  • 128
  • 190
7heViking
  • 7,137
  • 11
  • 50
  • 94
  • 2
    $Sometimes$ Android Studio will prompt to upgrade (with a non-modal popup at bottom-right of screen), if you click the link on that another popup (this time modal) will display in the middle of the screen, you should check what you are upgrading from before accepting but the modal nature means you need to dismiss it...then wait for that $sometime$ situation to happen again (if you want to do it via the popups...). This is a message for Android Studio Tooling team: let us trigger that popup flow. – straya Sep 26 '19 at 04:56

18 Answers18

593

Step 1 (Use default gradle wrapper)

FileSettingsBuild, Execution, DeploymentBuild Tools→GradleUse default Gradle wrapper (recommended)

Android studio settings Gradle Wrapper

Changing to Gradle Wrapper in the new version of Android Studio: Android Studio Setting Gradle Wrapper new version

Step 2 (Select desired gradle version)

FileProject StructureProject

Android Studio project structure

The following table shows compatibility between Android plugin for Gradle and Gradle:

Compatibility table

Latest stable versions you can use with Android Studio 4.1.2 (March 2021):

Android Gradle Plugin version: 4.1.2
Gradle version: 6.5

Official links

vovahost
  • 34,185
  • 17
  • 113
  • 116
  • 2
    With all these steps: Gradle 'Project' project refrash failed. Error: Cause: ....../gradle-3.0.0-all.zip – rommex Dec 06 '17 at 07:46
  • 1
    @rommex It's most likely that you're using an incompatible version. Check the Compatibility table to pick the correct one. – vovahost Mar 19 '18 at 09:18
  • this is only how to setup your default gradle, but it doesn't update it... If you have it configured to update automaticaly, so explain that, not this. Thanx – Ari Waisberg Jun 18 '18 at 18:50
  • @AriWais What do you mean ? To update Gradle Plugin and Gradle just increase the version as I showed above but remember to use compatible versions. – vovahost Jun 19 '18 at 09:33
  • 1
    for me it didn't... I did what you said and I receive an error "gradle version not installed" so I had to download it manually from gradle.org – Ari Waisberg Jun 28 '18 at 12:56
  • @AriWais Maybe you're using an old version of Android Studio. – vovahost Jun 28 '18 at 14:18
  • Updated it in an old project and it worked. After this process I needed to make a couple of instalations android studio told me to do so. It took me around 20 minutes to finsh the process and then I was able to run this old project. – Soon Santos Jul 11 '18 at 14:32
  • Should I also update the version number in the toplevel build.gradle under `buildscript { dependencies { classpath 'com.android.tools.build:gradle:3.13' } ... }`? – ki9 Jul 17 '18 at 00:10
  • 1
    @Keith No, past self! Don't do that: that's the "plugin version". Set that to 3.1.3 – ki9 Jul 17 '18 at 00:38
  • Had to just upgrade Gradle to 4.7 to work with the Spek 2.x framework. Thanks! – EM-Creations Nov 18 '18 at 16:50
  • Google, what a mess! Here are some suggested points which someone might want to edit into the current answer. As of v3.4.2, AS lets you type any version you want into the Gradle Version textbox, and the drop-down has no suggestions even when using the "default" (internal, recommended) gradle wrapper. So go into the AS/gradle folder and see what version you have. I have 5.1.1, so I typed that in and ended 20 minutes of frustration. (4 years since I last used AS.) – Nick Westgate Jul 25 '19 at 06:53
  • Gives this error: https://stackoverflow.com/questions/53709282/cannot-add-task-wrapper-as-a-task-with-that-name-already-exists – Kasra May 14 '20 at 07:03
  • 1
    In the latest version of AS, the option in step 1 is called "Use Gradle from gradle-wrapper.properties file" rather than "Use default Gradle wrapper" – Adam Burley Mar 16 '21 at 18:21
  • This answer is no longer valid as of today. When you enter the options in step 1, not all of the options listed there are displayed https://i.imgur.com/bCnqiFN.png – MrEduar Aug 16 '21 at 18:12
  • @MrEduar Thank you. I've added the screenshot for the new version as well. – vovahost Aug 19 '21 at 14:42
  • 4
    This answer is no longer valid, because of the changes in UI in Android studio. – Cyber Aug 05 '22 at 09:29
  • I don't have a Build Tools option. – chovy Aug 30 '22 at 10:29
  • @chovy Which Android Studio version are you using? – vovahost Aug 31 '22 at 04:47
96

This may not be the exact answer for the OP, but is the answer to the Title of the question: How to Update Gradle in Android Studio (AS):

  • Get latest version supported by AS: http://www.gradle.org/downloads (Currently 1.9, 1.10 is NOT supported by AS yet)
  • Install: Unzip to anywhere like near where AS is installed: C:\Users[username]\gradle-1.9\
  • Open AS: File->Settings->Gradle->Service directory path: (Change to folder you set above) ->Click ok. Status on bottom should indicate it's busy & error should be fixed. Might have to restart AS
Kevin
  • 2,296
  • 21
  • 22
60

after release of android studio v 3.0(stable), It will show popup, If gradle update is available

OR

Manually, just change version of gradle in top-level(project-level) build.gradle file to latest,

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

check below chart

The Android Gradle Plugin and Gradle

 Android Gradle Plugin            Requires Gradle
 1.0.0 - 1.1.3                    2.2.1 - 2.3
 1.2.0 - 1.3.1                    2.2.1 - 2.9
 1.5.0   2.2.1+                   2.2.1 - 2.13
 2.0.0 - 2.1.2                    2.10  - 2.13
 2.1.3 - 2.2.3                    2.14.1+
 2.3.0+                           3.3+
 3.0.0+                           4.1+    
 3.1.0+                           4.4+    
 3.2.0 - 3.2.1                    4.6+    
 3.3.0 - 3.3.1                    4.10.1+ 
 3.4.0 - 3.4.1                    5.1.1+
 3.5.0                            5.4.1+

check gradle revisions

Community
  • 1
  • 1
Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
  • 9
    Is there a way to trigger this popup manually? I started Android Studio 3.0 while the SDK Update was running in the background (not using AS for SDK management), so I clicked "Ask again tomorrow" just in case this would rely on the new Build Tools which the SDK Update was installing. – Daniel F Oct 26 '17 at 10:51
  • ok but you can change it by updating it in application level .gradle file@DanielF – Amit Vaghela Oct 26 '17 at 12:33
  • 15
    @DanielF close your project, then open the `.idea/workspace.xml` and remove the line `` (you might need to search for it). Save the file and open the project again. – Rolf ツ Nov 21 '17 at 10:45
48

Open File > Project Structure > Project Tab

Instructions

Android Studio has a built in project structure menu to check and update the gradle and plugin used in the current project.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Jayakrishnan
  • 4,457
  • 29
  • 29
  • 3
    So many different answers on how to resolve this and this was finally the secret handshake I needed to know. – spartygw Jun 04 '18 at 15:16
17

You can try "AGP (Android Gradle Plugin) Upgrade Assistant..." from the Tools menu.

AGP Assistant

Andrew T.
  • 4,701
  • 8
  • 43
  • 62
icgoogo
  • 401
  • 5
  • 7
16

For those who still have this problem (for example to switch from 2.8.0 to 2.10.0), move to the file gradle-wrapper.properties and set distributionUrl like that.

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

I changed 2.8.0 to 2.10.0 and don't forget to Sync after

Cedriga
  • 3,860
  • 2
  • 28
  • 21
  • No, if you only change this file, your project will can not be sync settings. You should change through Project Structure. – dalmate Jun 02 '19 at 09:57
9

On Mac, open terminal and run the following commands as per instructions:

$ curl -s https://get.sdkman.io | bash

then

$ sdk install gradle 3.0

Once the installation is complete, the terminal would ask whether to set it as a default version so type y and make it the default version.

Now open Android Studio -> Terminal and run the following command

Gradle --version
zeeawan
  • 6,667
  • 2
  • 50
  • 56
  • 2
    Worth noting that you will need to restart your shell or (in bash) `source ~/.bash_profile` to make the `sdk` executable if it's not already in your path – lucygenik Nov 03 '16 at 19:38
  • 12
    I'd be very wary of curling [internet] | bash, especially when following the instructions posted by a (essentially) anonymous post to a random website. – Amoliski Jan 10 '17 at 18:43
  • download a file and piping it straight into bash **checking the file in an editor to see what it does** ? – Martin Apr 08 '19 at 08:08
6

Open your root build.gradle file and change Gradle version like this

Old version:

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

New version:

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

For Gradle version compatibility see this.

Venu
  • 348
  • 4
  • 17
4

I can't comment yet.

Same as Kevin but with different UI step:

This may not be the exact answer for the OP, but is the answer to the Title of the question: How to Update Gradle in Android Studio (AS):

  • Get latest version supported by AS: http://www.gradle.org/downloads (Currently 1.9, 1.10 is NOT supported by AS yet)
  • Install: Unzip to anywhere like near where AS is installed: C:\Users[username]\gradle-1.9\
  • Open AS: File->Settings->Build, Execution, Deployment->Build Tools-> Gradle->Service directory path: (Change to folder you set above) ->Click ok. Status on bottom should indicate it's busy & error should be fixed. Might have to restart AS
QiMata
  • 216
  • 1
  • 7
3

Go to File > Settings > Builds,Execution,Deployment > Build Tools > Gradle >Gradle home path

Now, 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

Ashish Kapil
  • 102
  • 8
1

This works if you only need to set Gradle Version anew:

  1. Open Android Project Studio Settings: Go to File -> Settings -> Build, Execution, Deployment -> Android -> Android Project Structure
  2. Select Project
  3. Choose the Gradle Version which is compatible to the Gradle Plugin you're using Navigate to Android Project Structure to set the Gradle Version
Anna29545
  • 11
  • 3
0

It works for me:

just go to '/home/your-user/.gradle/wrapper/dists/'

delete everything inside of this

It will be replaced by android studio

on terminal run: ionic emulate android

Its all...

Tom Costa
  • 7
  • 3
0

For me I copied my fonts folder from the assets to the res folder and caused the problem because Android Studio didn't accept capitalized names. I switched to project view mode and deleted it then added it as font resource file by right clicking res folder.

fullmoon
  • 8,030
  • 5
  • 43
  • 58
0

Most of the time you can have Android Studio automatically update the Gradle plugin.

If your Gradle plugin version is behind, Instant Run will mostly likely not work. Therefore if you go to the Instant Run settings (Preferences > Build, Execution, Deployment > Instant Run), you'll see an Update project button at the top right (image below). Clicking this will update both the Gradle wrapper and build tools. Update Project

Mehmet K
  • 2,805
  • 1
  • 23
  • 35
  • Not true in all configurations – Ben-J Mar 02 '18 at 09:39
  • Hence the twice mention of 'most of the time' – Mehmet K Mar 02 '18 at 09:40
  • lol the method may be available or not, it does not affect the status of your code or application. If it option is there use it and i'll upgrade your gradle, if it isn't there you wont be able to use it and you can try another method. Are you literate? If you misunderstand tiny paragraphs most of the time, I am worried for you :) – Mehmet K Mar 02 '18 at 09:46
  • There is no "Instant Run" section now in preferences (AS 4.1.3). This answer is obsolete. – Vadim Kotov Apr 27 '21 at 16:10
0

Select android\gradle\wrapper and open gradle-wrapper.properties

change: distributionUrl=https://services.gradle.org/distributions/gradle-older-version-to-new-version.zip

eg: distributionUrl=https://services.gradle.org/distributions/gradle-5.1.1-all.zip and rebuild your project

0

Other answers mentioned how to update AGP (Android Gradle Plugin).

For updating Gradle itself, if you have set the IDE settings to use Gradle from the wrapper file or the wrapper task (as opposed to using a Gradle installed on your system, if any)...

Setting the Gradle used by the IDE

...you can specify the following code in your top-level build.gradle[.kts] script:

tasks.wrapper {
    gradleVersion = "7.3.3"
    // Downloads the full version of the Gradle (with sources and documentation)
    distributionType = Wrapper.DistributionType.ALL
}

Now, instead of editing gradle-wrapper.properties file, run the wrapper task and Sync the IDE:

OS Command
Linux ./gradlew wrapper
Windows Command Prompt gradlew wrapper
Mahozad
  • 18,032
  • 13
  • 118
  • 133
0

Try this command in the command line:

./gradlew wrapper --gradle-version latest
user16217248
  • 3,119
  • 19
  • 19
  • 37
Milad Targholi
  • 102
  • 1
  • 8
-12

If your run button is gray. This is how i fixed it.

Go to Run in menu, and then press this:

enter image description here

Then it will run your Emulator, and your run button will become green again and you can use it. That is how i fixed it.

Miljan Rakita
  • 1,433
  • 4
  • 23
  • 44