0

Why does Android Studio build the entire project after a single letter change and Run?

Lets say I have the magic number 42 in a class, and I change it to 43. I had just run the project, and now I click Run again.. another 2 minutes of waiting!!!

Sometimes I even run the same thing twice in a row without changes at all and it builds the entire thing from scratch anew.

Is there a way to configure Gradle to behave a bit smarter?

Kaloyan Roussev
  • 14,515
  • 21
  • 98
  • 180
  • 1
    In my case, I noticed that it was taking too much time at ZipAlign proccess. So, I disable it during debug compilation by adding: "zipAlignEnabled false" in my build.gradle. When build, open gradle console (right-bottom edge) and observe which proccess is taking too much time. – guipivoto Mar 08 '16 at 22:44

1 Answers1

2

Your solution is Android Studio 2.0. It has "Instant Run" feature. It uploads app instantly. Android Studio 2.0 is in beta channel right now. You can download it from here.

And about instant run feature you can find detailed article here.

If you don't want to use beta version, another solution could be setting daemon true. You can see how too set gradle daemon true in this link.

Hope these will work for you :)

Mithun
  • 2,075
  • 3
  • 19
  • 26
emin deniz
  • 439
  • 5
  • 13
  • thanks, when will 2.0 be officially stable and ready for use? And do you know why does Gradle build the whole thing from scratch every time? – Kaloyan Roussev Mar 08 '16 at 22:51
  • Im going to test the second suggestion these days – Kaloyan Roussev Mar 08 '16 at 22:54
  • I don't know when it will release in stable channel actually. But I believe it will be soon. I don't know why gradle does this actually but sometimes it drives me crazy too. About faster gradle there are lots of articles and questions in web. I can suggest this question especially. Answers are really usefull. http://stackoverflow.com/questions/16775197/building-and-running-app-via-gradle-and-android-studio-is-slower-than-via-eclips[link] – emin deniz Mar 08 '16 at 23:00
  • Android studio is in stable channel for your information :) – emin deniz Apr 14 '16 at 11:02