How to Speed Up Gradle build in Android Studio?
Last Updated :
22 Mar, 2021
Gradle is one of the most important files or extensions that are present in the Android Project. Gradle handles all the libraries and application IDs and many important components of any Android application. Every time when we run our application or we build our apk we will get to see the message as Gradle build running and many more. In some devices, Gradle works very fast whereas in some devices it takes so much time to load and build your application.
10:03:51 Gradle build finished in 4 min 0 sec
10:04:03 Session 'app': running
10:10:11 Gradle build finished in 3 min 29 sec
10:10:12 Session 'app': running
10:20:24 Gradle build finished in 3 min 42 sec
10:28:18 Gradle build finished in 3 min 40 sec
10:28:19 Session 'app': running
10:31:14 Gradle build finished in 2 min 56 sec
10:31:14 Session 'app': running
10:38:37 Gradle build finished in 3 min 30 sec
10:42:17 Gradle build finished in 3 min 40 sec
10:45:18 Gradle build finished in 3 min 1 sec
10:48:49 Gradle build finished in 3 min 30 sec
10:53:05 Gradle build finished in 3 min 22 sec
10:57:10 Gradle build finished in 3 min 19 sec
10:57:11 Session 'app': running
So in this article, we will take a look at optimizing the speed of our Gradle in the Android Studio Project. We are going to discuss 4 different methods for doing this task.
- Method 1: Offline mode for Gradle
- Method 2: Using a specific library for google play services
- Method 3: Removing proxy
- Method 4: Avoid using more external dependencies in your project
Method 1: Offline mode for Gradle
Many times when we are building any application or running it on our device or emulator. We will get to see that Gradle connects with our internet and downloads the files from the internet. This process sometimes takes so much time which will depend on your internet connection. So to avoid downloading these files we have to enable offline mode for our android studio for Gradle files to avoid downloading of these files. Below are the steps in which we will be enabling offline mode in our application. Click on the File option which is shown in the top bar of Android Studio. Inside that click on the Settings option. You can get to see the Settings option in the below screen.

After clicking on the settings option you will get to see the below dialog. Inside this dialog navigate to the Build, Execution, Deployment option and then click on the Gradle option. After that uncheck the option for Download external annotations and dependencies and after that click on Apply option and then click on the OK option to proceed further. After that we have enabled offline mode for Gradle has been enabled in our android studio project. Now due to offline mode, the loading time for your Gradle will be reduced to a certain extent.

Method 2: Using a specific library for google play services
When we are adding services provided by google in our application we add the below dependency in our build.gradle file. This dependency is having features of all the services present in it. So this dependency is quite heavy and due to this, it will load several times when we build our application.
implementation ‘com.google.android.gms:play-services:8.3.0’
Instead of using this dependency, we should use the dependency of a specific service that we have to use in our application. Let’s suppose we have to use maps service in our application so for that we will be specifically adding the dependency for maps rather than adding the above dependency. This will only provide us the support for using maps. This dependency will take lesser time to load compared to the one which we have used above.
implementation ‘com.google.android.gms:play-services-maps:8.3.0’
Method 3: Removing proxy
If Android Studio has a proxy server setting and can’t reach the server then it takes a long time to build, probably it’s trying to reach the proxy server and waiting for a timeout. By removing the proxy server setting it’s working fine. Steps to Removing proxy: File > Settings > Appearance & Behavior > System settings > HTTP Proxy.

Method 4: Avoid using more external dependencies in your project
When we add many dependencies in our Android Studio project it will take much time to compile your android studio project and also manages all the dependencies in your android studio project. As the Gradle file manages all the dependencies of our project so we should use fewer number dependencies which will help us to reduce the time required for the Gradle to sync each time when we create a new apk or run our application in an emulator or device.
Similar Reads
How to Update Gradle in Android Studio?
The Android Studio build system is based on Gradle, and the Android Gradle plugin adds several features that are specific to building Android apps. Although the Android plugin is typically updated in lock-step with Android Studio, the plugin (and the rest of the Gradle system) can run independent of
2 min read
How to Speed Up Android Studio?
A slow Android Studio is a pain in the butt for an android developer. Developing an application with a slow IDE is not a cakewalk. It's also annoying that when you are focusing on the logic building for your app, and you got a kick to work and at that time your android studio suddenly starts lagging
7 min read
How to Generate Signed AAB File in Android Studio?
In this article, you will learn how to create an Android App Bundle (AAB) file for an Android app. An Android App Bundle is a publishing format that includes all your appâs compiled code and resources. Your application should be digitally signed with a key in order to publish it on the Google Play s
2 min read
How to Generate Signed Apk in Android Studio?
Signed Apk generates a key and this key can be used to release versions of the app, so it is important to save this key which will be used when the next version of the app is released. The Android system needs that all installed applications be digitally signed with a certificate whose private key i
3 min read
How to Build Age Calculator in Android Studio?
Hello geeks, today we are going to make an application to calculate Age or time period between two dates. By making this application one can calculate his/her exact age, also one can calculate the exact difference between two dates. Prerequisites: Before making this application, you can go through t
6 min read
How to Generate Unsigned (Shareable) Apk in Android Studio?
Unsigned Apk, as the name suggests it means it is not signed by any Keystore. A Keystore is basically a binary file that contains a set of private keys. Every App that we install using the Google Play App Store needs to be signed with a Keystore. The signed apk is simply the unsigned apk that has be
2 min read
How to Speed Up Android Emulator?
Android Emulators are an important part of the android development environment. For creating awesome apps, Developers needs to test their app on different types of android devices. Devices can be real and virtual as well. The advantage of having an android emulator (virtual android device) is that t
6 min read
How to Change the API SDK Level in Android Studio?
Generally, API level means the Android Version. This determines which version the developers are targeting their application and what is going to be the minimum level of the android version in their application will run. For setting the Minimum level and Maximum level android studio provides two ter
2 min read
How to Build a Sensor App in Android?
Android mobile phones have sensors, so we can perform various functions like Controlling screen brightness, Monitoring acceleration along a single axis, Motion detection, etc. In this article, we will be building an application that will determine the intensity of light in the room with the help of
5 min read
How to Remove Firebase Authentication in Android Studio?
Android Studio is the official IDE (Integrated Development Environment) for Android app development and it is based on JetBrainsâ IntelliJ IDEA software. Android Studio provides many excellent features that enhance productivity when building Android apps, such as: A blended environment where one can
2 min read