6

I am building an android app with android studio.

In the process I am also implementing facebook login, which requires me to put a folder's worth of code into my project, among other compile-time libraries.

Each time that I compile (and run) my app while testing it, it is currently taking 3 minutes to compile!

I want to know if there is a way to specify that unmodified classes do not need to be recompiled? I am trying to speed up my build time so that I can be more productive.

Any other advice on how to make my project build faster for testing / debugging / release?

Thanks.

user198923
  • 489
  • 1
  • 7
  • 19

3 Answers3

8

In gradle.properties, add the following two lines:

org.gradle.daemon=true
org.gradle.parallel=true
Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
1

You could enable "offline work" for Gradle. In Android Studio open the Preferences Dialog. Next select Gradle in the categories (on the left) and activate the checkbox "Offline work".

In my projects this speeds up compiling because dependencies are not rechecked while compiling (I guess). So once all dependencies of your app has been loaded and compiled you can start working offline. Remember to enable "online work" if you change dependencies or versions of your dependencies.

sockeqwe
  • 15,574
  • 24
  • 88
  • 144
0

You can always increase the heap space available. The more ram you dedicate the better the compilation time would be.

Here is a useful post on how to go about that.

Community
  • 1
  • 1
SeahawksRdaBest
  • 868
  • 5
  • 17
  • 1
    This is actually likely to make the problem worse. – Scott Barta Sep 30 '14 at 19:07
  • Why do you say that? more available RAM at Studios disposal always helps me. That is to say I do in fact have 32gb so I could potenially dump a lot of extra on it – SeahawksRdaBest Sep 30 '14 at 19:09
  • 1
    The builds don't happen in Android Studio's process space, so if you give Android Studio more RAM, there will be less left over for the actual build. Gradle's daemon process takes up to several hundred megabytes by default (and some configure it to have 1 GB), but most of the build happens in subprocesses forked off by Gradle. – Scott Barta Sep 30 '14 at 19:12
  • In eclipse I know for sure the process becomes faster. I know because of personal experience that the "compilation" time reduced substantially. Furthermore if he is launching a AVD then there is no doubt more ram is going to help. – SeahawksRdaBest Sep 30 '14 at 20:03