Does your Android Studio takes a lot of time to build and run??

If you have a low-end pc, then this time increases.

When I hit the run button, I sit and wait for gradle to get finished. One minute is gone, two minutes, three minutes.

In my old PC, Waiting has passed more than 30 minutes.

That affected my productivity very badly.

End of the day, I feel miserable, nothing is done, Still waiting for gradle build completion.

At that time, Just like any other beginner, I searched on Google “How to reduce Android build time”. But nothing gets worked.

Then I learned about the Gradle build system. after that, I got to know we can run the project using Commands.

So in this post, I will tell you a way that I am using which reduced my APK build time.

Yes, this is really interesting and It will be useful in the long run.

Before that, let’s make a simple talk about Gradle and gradlew.

What is gradle and gradlew??

Gradle is a build tool which makes APK using our source code and resources like layouts, images by giving them to suitable tools. When you click the run button, Android Studio delegates power to gradle and wait for it to finish just like us.

gradlew file in root project folder of Android studio -Efficient way to reduce android build time

gradlew is a batch file in Windows. In Mac and Linux, it available in the form of a shell. You could find it on the Android Studio project’s root directory. It has the ability to pass commands to gradle. Using those commands we can make Gradle work. gradlew is also responsible for downloading gradle from the Internet.

If you are in the Android Studio project folder, Open your command prompt and Just type gradlew and press enter. The script runs and looking for a gradle in your system. If the desired one not found, It goes online and downloads gradle.

Let’s find out how to build APK using gradlew.

  1. Open the command prompt and navigate to the root folder of your project.
  2. Make sure that you enabled USB debugging on your device and still connected.

  3. Type ‘gradlew installdebug (‘without quotes) in command prompt and press enter key.

    This command will start building process with the use of the gradlew.bat file.
    gradlew installdebug

    If there are no errors, The APK will be moved and installed on your smart device.

    Just tap on the app icon manually to launch.

    Other commands

    1. gradlew -version – It shows us gradlew, groovy, JVM and OS versions.
    2. gradlew clean – Cleans the project by deleting build directory , actually reduces your project size.
    3. gradlew tasks – Shows all tasks.
    4. gradlew unInstallDebug – Uninstalls the app
    5. gradlew wrapper – Generates wrapper files.
    6. gradlew –help – Shows list of command line options.
    7. Want to know more about build apps through command line


      Everybody hates to be waited, there no change in build time too. Build takes so much time from our life and it increases the development period. High-level PC and gradlew installdebug command can help you to save your valuable time. Using gradlew and Gradle we can do so much stuff. If there is any other technique you use. Feel free to comment here and please share this article. Thank you, guys.

Please disable your adblocker or whitelist this site!