My Android Studio project used to build faster but now it takes a long time to build. Any ideas what could be causing the delays? I have tried https://stackoverflow.com/a/27171878/391401 but no effect. I dont have any Anti virus running which could interrupt the builds. My app is not that big in size as well (around 5MB) and it used to build within few seconds but not sure what has changed.
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
If you are using Google Play services, make sure you aren't using this in your Gradle build script:
Only use those Google APIs that your app is really using. If all you are using is Google Maps, you would use this:
When I did this, my compile time went from over 2 minutes to around 25 seconds. For a list of the Google apis that you can selectively compile against, see:
https://developers.google.com/android/guides/setup
In the beta version of Android studio 2.0, they've rolled out a feature called Instant Run. It reduces the build time by a big factor. The core concept is, Android Studio only pushes the small changes made into an already running app.
It classifies the changes we make in our code to three parts: hot swap, warm swap and cold swap, based on how much load would the change would put on the build. After that, it simply swaps the code in the already running app and we get could see the changes running a few seconds. See their doc for more information.
Here you can download Android Studio 2.0 preview.
PS: There are a few issues with this feature. They've listed it out at the docs. Check it out before installation.
Found an easy and best way to build gradle
go to your app >> open your gradle.properties and change few lines from it [remove #]
else you may copy paste my below snippet as well
it worked for me earlier it take almost 2-3 minutes now it is taking only 5-6 second
in above scenario my mac machine have 8GB ram so i assigned 4gb for gradle
If you're using Windows 8...
DroidArc and AndroidDev solutions where useful, but not enougth. My problem was related with my Windows 8 OS and its 100% disk usage.
Especially the Windows Search service, was the most consuming. Disable it with: cmd(Admin) >net.exe stop "Windows search"
I followed the directions in this link and it solved the problem for real 4 Tips to Fix 100% Disk Usage & Improve Windows Performance
Hope this helps.
In your build.gradle, if you have minifyEnabled for debug, remove it. I had it in my project and it took ~2-3 minutes to build. After looking at build progress, I found this as culprit, so deleting the commented line below, my issue was fixed.