4

When Instant Run is enabled, the full build will take up my 100% of my cpu. The macbook is lagging and almost unusable.

Build times:

Command line: 
Total time: 1 mins 35.025 secs

Android Studio:
Total time: 4 mins 23.928 secs

If instant run is disabled, I get the same times as on the command line. When profiling the full build I notices that app:transformClassesWithDexForDebug takes up to 3 minutes.

Is there a way to improve the performance on a clean build with instant run enabled?

Macbook 10.11.5 / Core i7
Android Studio 2.1.1
Gradle tools 2.1.0

gradle.properties

org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx5120M
Ion Aalbers
  • 7,830
  • 3
  • 37
  • 50
  • check [this](http://stackoverflow.com/a/37207831/2826147) and [this](http://stackoverflow.com/a/37207831/2826147) SO answer – Amit Vaghela Jul 05 '16 at 11:11
  • I had cold start 1 min in Android Studio. After adding Dagger 2 with "android-apt" it's taking 10 mins on cold start (but still 1 min in command line). Any idea why Instant Run is slow with "android-apt"? – surlac Jul 28 '16 at 01:59

3 Answers3

0

you can try to set

minSdkVersion = 21

in your module's build.gradle to get best performance of instant Run.

Source: link

Mehta
  • 1,228
  • 1
  • 9
  • 27
0

Another way to solve your long build times is to turn off Instant Run as follows:

Settings → Build, Execution, Deployment → Instant Run and uncheck Enable Instant Run.

Phileo99
  • 5,581
  • 2
  • 46
  • 54
  • Like I stated in my question, I want to improve the cold build time with Instant Run Enabled – Ion Aalbers May 27 '16 at 15:40
  • try these suggestions: http://stackoverflow.com/a/35446359/923920 . If that doesn't work then report the bug here: https://code.google.com/p/android/issues/detail?id=210490&thanks=210490&ts=1463708488 – Phileo99 May 27 '16 at 18:24
0

You can improve build times by experimenting with DEX resources

android {
  ...
  dexOptions {
    maxProcessCount 4 // this is the default value
    javaMaxHeapSize "2g"
  }
}

minSdkVersion should 15 or higher to get any profit.

Still you can encounter some bugs and glitches.

I had the same issue - cold start for 5-6 min and heating cpu like hell...

With more or less complex project this feature is buggy, so I turned it off.

Maxim G
  • 1,479
  • 1
  • 15
  • 23