Android Studio builds Android projects with the default Gradle property settings. If you find the build process taking a long time and your computer has adequate memory, it is possible to tweak the settings to allocate more memory to the build process to reduce the compilation time.
In Android Studio, open up the top level gradle.properties file to change the settings, as shown below.
In the editor, locate the commented line with the string "org.gradle.jvmargs", and make a copy of it directly underneath; then remove the # character to un-comment it.
An example of an edited gradle.properties file is shown below.
Now, the build process should complete faster.