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
Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co
11 min read
Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance
10 min read
Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact
12 min read
Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and
9 min read
3-Phase Inverter An inverter is a fundamental electrical device designed primarily for the conversion of direct current into alternating current . This versatile device , also known as a variable frequency drive , plays a vital role in a wide range of applications , including variable frequency drives and high power
13 min read
Polymorphism in Java Polymorphism in Java is one of the core concepts in object-oriented programming (OOP) that allows objects to behave differently based on their specific class type. The word polymorphism means having many forms, and it comes from the Greek words poly (many) and morph (forms), this means one entity ca
7 min read
CTE in SQL In SQL, a Common Table Expression (CTE) is an essential tool for simplifying complex queries and making them more readable. By defining temporary result sets that can be referenced multiple times, a CTE in SQL allows developers to break down complicated logic into manageable parts. CTEs help with hi
6 min read
What is Vacuum Circuit Breaker? A vacuum circuit breaker is a type of breaker that utilizes a vacuum as the medium to extinguish electrical arcs. Within this circuit breaker, there is a vacuum interrupter that houses the stationary and mobile contacts in a permanently sealed enclosure. When the contacts are separated in a high vac
13 min read
Python Variables In Python, variables are used to store data that can be referenced and manipulated during program execution. A variable is essentially a name that is assigned to a value. Unlike many other programming languages, Python variables do not require explicit declaration of type. The type of the variable i
6 min read
Spring Boot Interview Questions and Answers Spring Boot is a Java-based framework used to develop stand-alone, production-ready applications with minimal configuration. Introduced by Pivotal in 2014, it simplifies the development of Spring applications by offering embedded servers, auto-configuration, and fast startup. Many top companies, inc
15+ min read