Follow these steps:
Step 1:
Go to Android -> Preferences
Click on Build, Execution, Deployment
Click on -> Compiler
Check the Option — Compile independent modules in parallel (may require larger heap size)
Check on Use in-process build” and “Configuration on demand and click OK button
Restart Android Studio and that’s it.
Step 2:Update your android studio vm options file
Find your Android Studio app launcher file
Right click the icon -> Select “Show Package” Contents”
Go to Contents -> Bin folder
Open “studio.vmoptions” file using text editor
Add/change the following lines in your file and save it.
Old Options
-Xms256m
-Xmx1280m
-XX:MaxPermSize=700m
-XX:ReservedCodeCacheSize=240m
Newly Updated Options (You can even increase more based on your Mac or PC’s RAM speed)
-Xms512m
-Xmx2560m
-XX:MaxPermSize=700m
-XX:ReservedCodeCacheSize=480m
Step 3: Restart or start the Android Studio
Step 4: In case if the Android Studio doesn’t open, which means you’re old vm option file got cached somewhere.
Follow these simple commands in your command line and remove the old file.
cd ~/Library
cd Preferences
cd AndroidStudio3.1 (This should be your current Android Studio version )
rm studio.vmoptions