Define differences:

Gradlew is a wrapper that automatically downloads the gradle version defined in the wrapper to ensure a uniform build environment. Gradlew uses the local gradle version.
For Gradlew, it is specified in Android Studio in gradle/wrapper/gradle-wrapper.properties. For example, the following code specifies that the app is compiled with gradle version 4.1.
#Wed Mar 07 14:24:26 CST 2018distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME ZipStorePath = wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zipCopy the code

Different storage paths

For the system gradle it is stored under ~/. Gradle. Gradle2.12 can be found in this folder. For gradlew it is stored under ~ /.gradlew/wrapper/dists. There are many versions of Gradle below this. These are gradlew’s downloaded gradle versions.

Gradle versions vary

If you use gradlew on the command line you use a gradle script stored under ~ /. Gradlew /wrapper/dists, specified in the gradle/wrapper/gradle-wrapper.properties file. If you use the gradle command line, you use the gradle script under ~/. Gradle.

Verification test

I put the following code under build.gradle of AS.
task hello1 << {
    println 'hello1'
    println GradleVersion.current().toString()
}
Copy the code
Run the task using the gradlew command
./gradlew hello1

Copy the code
get
> Task :hello1
hello1
Gradle 4.1

Copy the code
Instead, run tasks using the gradle command
gradle hello1
Copy the code
get
   > Minimum supported Gradle version is 3.3. Current version is 2.12.
   
Copy the code
This is the same as what I analyzed before. The above analysis is correct.
The resources
  1. https://docs.gradle.org/current/userguide/gradle_wrapper.html
  2. http://saiwei.me/?p=3747