What is gradle wrapper and the gradlew.bat file?

Viewed 39501

Lately I came to know the power of Gradle as a build system and as an Android developer I wanna understand it deeply.

One article said the following:

You can execute all the build tasks available to your Android project using the Gradle wrapper command line tool. It's available as a batch file for Windows (gradlew.bat) and a shell script for Linux and Mac (gradlew.sh), and it's accessible from the root of each project you create with Android Studio.

To run a task with the wrapper, use one of the following commands:

  • On Windows:
    gradlew task-name
    

Now I have some doubts which goes as follow:

  1. What is Gradle Wrapper and gradlew.bat?
  2. If I've got Android studio installed and it is using gradle to build my apps (so gradle is already installed on my system), do I still need to install gradle for build purpose from command line? As when i write any commend like gradle, gradlew on my command line I get error saying gradlew is not recognized as internal or external command (the same error for other commands). I may be using it on wrong path, help me on what path do I need to use Gradle related command?
  3. If I need to download and install it, how and where can I find the file? And the other processes?

I am using a Windows machine for this.

3 Answers
Related