Speed up your Android Studio to get some more time to build better apps
Kirtan Thakkar
Life is all about learningIf you are an android developer, you know how much time it takes to get your code compiled. It's pretty annoying to wait for your builds to complete. Fortunately, there are some ways you can improve your builds. Go ahead and try out below mentioned methods. You will definitely see improvements.
Use gradle daemon
Gradle daemon will speed up your build's start time. Because it doesn't have to start the gradle every time build happens. You can enable this option by adding a line into the gradle.properties
file. Open and add the following line at the bottom:
Use Incremental Dex
This option will use incremental dex builds for your app. Which will reduce the build time by rebuilding its outputs by only building if an input file has been modified.
Add below lines in your app's build.gradle
file inside the android { ... }
block:
Use Dex In Process
Reto Meier, Developer Advocate @ Google has shared a pro-tip for faster Android Studio builds using Dex In Process. You can read the full article here.
Update your jvm args in the gradle.properties
to minimum 2 Gb, to enable Dex In Process:
Watch the below video for more details:
Set high priority for Android Studio and Gradle processes
Now this one is a bit weird, but I have actually seen a very good results with this. If you are using a windows, open your task manager and go to processes. Now this may very based on your windows version. Find a tab in task manager which displays a list of processes (Details tab if you are using Windows 10).
- Find
studio.exe
orstudio64.exe
andjava.exe
. - Click to highlight that process -> Right click -> Set priority -> Realtime. Do this for both the processes.
This will allocate more CPU cycles to these processes which results in lesser build time or faster builds.
Note: Don't worry if you see some lag in your cursor when your gradle build is running. Just wait for the build to finish. However, you can also set high priority instead of realtime.
So, these are few tweaks which can get you some more time to #BuildBetterApps.