How to determine the version of Gradle?

2019-01-17 05:37发布

问题:

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.

回答1:

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.



回答2:

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"


回答3:

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.