234

How can I know which version of Gradle I am using in my Android Studio? Please guide.

I want to make sure I am using Gradle version 2.2.1.

Bryan Herbst
  • 66,602
  • 10
  • 133
  • 120
  • 1
    In `build.gradle` you will find the version – Roon13 May 05 '15 at 13:57
  • 14
    @Roon13 No. in `build.gradle` you can find the plugin from android. The version of gradle is in `gradle/wrapper/gradle-wrapper.properties` – Gabriele Mariotti May 05 '15 at 13:59
  • Check here about different concepts of gradle version. https://stackoverflow.com/a/51392464/8034839 I.e. gradle version. Android Gradle plugin version and Android gradle wrapper. – shizhen Oct 24 '18 at 14:16

13 Answers13

274

Option 1- From Studio

In Android Studio, go to File > Project Structure. Then select the "project" tab on the left.

Your Gradle version will be displayed here.

Option 2- gradle-wrapper.properties

If you are using the Gradle wrapper, then your project will have a gradle/wrapper/gradle-wrapper.properties folder.

This file should contain a line like this:

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

This determines which version of Gradle you are using. In this case, gradle-2.2.1-all.zip means I am using Gradle 2.2.1.

Option 3- Local Gradle distribution

If you are using a version of Gradle installed on your system instead of the wrapper, you can run gradle --version to check.

Bryan Herbst
  • 66,602
  • 10
  • 133
  • 120
  • 2
    Regarding **Option 3** this would work also when using the wrapper. – Amnon Shochot May 05 '15 at 16:51
  • 24
    Yep, the only difference is that you should run `./gradlew --version` from your project's directory (or wherever your Gradle wrapper lives). – Bryan Herbst May 05 '15 at 16:52
  • Option 1 doesn't make sense, since the value is mutable. – nmz787 Aug 26 '16 at 07:57
  • @nmz787 if you are changing that value, then the question of "what version am I using" is awfully silly, isn't it? The value is whatever you are setting. If you aren't changing it, then that is precisely the version that your builds are currently using. – Bryan Herbst Aug 26 '16 at 15:07
  • 2
    I guess I was looking for "how to get all valid versions of gradle to use". Since I can enter 1234 for the version, but that doesn't actually mean it IS a version of gradle. – nmz787 Aug 26 '16 at 21:24
  • This is not technically correct. This file just indicates the version of gradle you have configured the project to use, and also should not be confused with the Android Gradle Plugin. For instance, you coul dhave multiple versions of Gradle installed on your system, and this file would only indicate the Gradle Version your project is ATTEMPTING to use. To actually determine which version of Gradle is installed on your system, which is what I believe OP is aksing, simply *open a terminal and type * This will indicate which Gralde Version your system is currently using. – Nicolas Mage May 12 '22 at 20:48
  • continued.... If you have the need to frequently switch between versions, I highly recommend sdkman as it is very easy ot set system defaults and also download specific versions. – Nicolas Mage May 12 '22 at 20:50
  • This question is specifically about Gradle, not the Android Gradle Plugin. The vast majority of Gradle users are also not using a version installed on their computer, and **should not be** because that leads to non-reproducible builds. However, I did include that version check as option three in case that is your configuration. – Bryan Herbst May 13 '22 at 14:44
  • Option 2 works for checking the gradle version used by the project – Akki Aug 02 '23 at 13:00
55

Gradle Wrapper

I running the following in my project using the Gradle Wrapper.

./gradlew --version

------------------------------------------------------------
Gradle 4.7
------------------------------------------------------------

Build time:   2018-04-18 09:09:12 UTC
Revision:     b9a962bf70638332300e7f810689cb2febbd4a6c

Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM:          1.8.0_212 (AdoptOpenJDK 25.212-b03)
OS:           Mac OS X 10.15 x86_64
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
cura
  • 1,035
  • 1
  • 17
  • 33
38

Build Script

You can also add the following line to your build script:

println "Running gradle version: $gradle.gradleVersion"

or (it won't be printed with -q switch)

logger.lifecycle "Running gradle version: $gradle.gradleVersion"
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
Opal
  • 81,889
  • 28
  • 189
  • 210
18

At the root of your project type below in the console:

gradlew --version

You will have gradle version with other information (as a sample):

------------------------------------------------------------          
Gradle 5.1.1 << Here is the version                                                         
------------------------------------------------------------          

Build time:   2019-01-10 23:05:02 UTC                                 
Revision:     3c9abb645fb83932c44e8610642393ad62116807                

Kotlin DSL:   1.1.1                                                   
Kotlin:       1.3.11                                                  
Groovy:       2.5.4                                                   
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018  
JVM:          10.0.2 ("Oracle Corporation" 10.0.2+13)                 
OS:           Windows 10 10.0 amd64                                   

I think for gradle version it uses gradle/wrapper/gradle-wrapper.properties under the hood.

Alireza Fattahi
  • 42,517
  • 14
  • 123
  • 173
8

Go to Terminal & Type:

gradlew --version


Gradle 5.3

Build time: 2019-03-20 11:03:29 UTC Revision: f5c64796748a98efdbf6f99f44b6afe08492c2a0

Kotlin: 1.3.21 Groovy: 2.5.4 Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018 JVM: 1.8.0_181 (Oracle Corporation 25.181-b13) OS: Mac OS X 10.14.6 x86_64

Deepika
  • 83
  • 1
  • 5
2

Another solution on windows is to locate the file "gradle.bat" (usually in Gradle\bin\ directory), then you launch it from the command line and you will get the version like so:

terminal

Amy
  • 1,114
  • 13
  • 35
Richard
  • 21
  • 1
2

Checking in gradle-wrapper.properties

Check your gradle-wrapper.properties in Android project/gradle/gradle-wrapper.properties.

You'll have something like this:
distributionUrl=https://services.gradle.org/distributions/gradle-6.5-bin.zip

Using terminal

Windows:

run gradlew --version

Mac:

run ./gradlew --version

in your project folder.

Jerin
  • 688
  • 1
  • 9
  • 21
1

I found the solution Do change in your cordovaLib file build.gradle file

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

and now make changes in you,

platforms\android\gradle\wrapper\gradle-wrapper.properties

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

this works for.

Mihir Patel
  • 416
  • 5
  • 13
1

If importing the project try doing following steps:

  1. Check Gradle version in command prompt gradle --version
  2. While importing the project like below enter image description here
Aamer
  • 417
  • 3
  • 9
1

Simple answer for windows 10 in android studio, open the terminal inside android studio, then ensure you are in your app, if not navigate to where your app is then enter this command without the double quotes "./gradlew --version"

sudip-modi
  • 86
  • 1
  • 6
0

Check in the folder structure of the project the files within the /gradle/wrapper/ The gradle-wrapper.jar version should be the one specified in the gradle-wrapper.properties

rockdaswift
  • 9,613
  • 5
  • 40
  • 46
-1

2019-05-08 Android Studios needs an upgrade. upgrade Android Studios to 3.3.- and the error with .R; goes away.

Also the above methods also work.

RVscript
  • 49
  • 3
-2

replace this line in android\build.gradle

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