Since the last update (Build from june 25) any changes in the Android studio Gradle is painfully slow. And it also seems to autotrack changes when you edit the file and recompile on keyup.
Each change takes several minutes on my i5.
Any idea how I can speed up my Gradle changes?
There is a newer version of gradle (ver 2.4).
You can set this for your project(s) by opening up 'Project Structure' dialog from File menu,
and set it to '2.4'.
You can read more about boosting performance at this link.
You can also use command line for better performance.You can use the command ./gradlew
<task name>
from inside the root folder of your project from linux or use gradlew.bat file like gradlew<task name>
.when you first run one of the commands above for a given Gradle version, it will download the corresponding Gradle distribution and use it to execute the build.When importing a Gradle project via its wrapper, your IDE may ask to use the Gradle 'all' distribution. This is perfectly fine and helps the IDE provide code completion for the build files. Not only does this mean that you don’t have to manually install Gradle yourself, but you are also sure to use the version of Gradle that the build is designed for. This makes your historical builds more reliable. for more info refer Executing a build with the Wrapper
For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB.
To do this set
org.gradle.jvmargs=-Xmx2048M
in the project gradle.properties.
With Android Studio 2.1 you can enable "Dex In Process" for faster app builds.
You can get more info about it here: https://medium.com/google-developers/faster-android-studio-builds-with-dex-in-process-5988ed8aa37e#.vijksflyn
After change this settings my compile time 10 mins reduced to 10 secs.
Step 1:
Step 2:
Step 3: In your gradle.properties file -> Add following lines
Update:
If you are using Android studio 2.0 or above try the Instant Run
More info about Instant Run - https://developer.android.com/studio/run/index.html#instant-run
Try to avoid using a Mac/PC that has only 8 GB of RAM when doing Android development. As soon as you launch even 1 emulator (Genymotion or otherwise), your build times become extremely slow in Android Studio with gradle builds. This happens even if you make a simple one-line change to 1 source file.
Closing the emulator and using a real device helps a lot, but of course this is very limiting and less flexible. Reducing the RAM usage setting of the emulator can help, but the best way is to ensure your laptop has at least 12-16 GB of RAM.
Update (June 2017): There are now several good medium.com articles that explain how to speed up Android Studio gradle builds in detail, and it even works on 8 GB machines:
The summarised consensus is:
Create a gradle.properties file (either global at
~/.gradle/gradle.properties
or local to project), and add the following lines: