5

I have been having horrible build time from android studio and I wanted to know if you have any tips for optimizations. Here is a bit of details on the app I'm currently working on:

  • 65k function limit issue, using the latest multidex fix from the support pkg
  • Uses around 10-15 Libraries
  • Uses 1-2 native libs (.so)
  • Tried using the pre-dex trick, results varies.
  • Build time before integrating twitter fabric ~ 1m30sec
  • Build time after integrating twitter fabric 4m30sec - 14m30sec

Hardware/Software spec:

  • i7 4240
  • 16GB RAM
  • 250GB SSD

Any tips, comments are most welcomed :)

EDIT 1

Added profiling results:

<div class="tab" id="tab0">
<h2>Summary</h2>
<table>
<thead>
<tr>
<th>Description</th>
<th class="numeric">Duration</th>
</tr>
</thead>
<tr>
<td>Total Build Time</td>
<td class="numeric">8m44.29s</td>
</tr>
<tr>
<td>Startup</td>
<td class="numeric">1.813s</td>
</tr>
<tr>
<td>Settings and BuildSrc</td>
<td class="numeric">0.038s</td>
</tr>
<tr>
<td>Loading Projects</td>
<td class="numeric">0.009s</td>
</tr>
<tr>
<td>Configuring Projects</td>
<td class="numeric">5.889s</td>
</tr>

http://jsfiddle.net/gp6o04dL/

Vannen
  • 712
  • 2
  • 7
  • 17
  • I had the same issue, with almost the same spec. Every change I've made to the sources caused a serious delay of up to 2 min until I could run it on the device, which got me extremely frustrated... Eventually I migrated the project back to Eclipse... now it takes 11 seconds for the application to install. – TacB0sS Dec 08 '14 at 09:56
  • 1
    Try building from the command line with the `--profile` flag, look at the profiling report it puts in `build/reports/profile/`, and include the information in your question. – Scott Barta Dec 08 '14 at 18:46
  • Added profiling results using gradlew build --profile – Vannen Dec 09 '14 at 10:50

2 Answers2

2

You may try with...

File -> Settings -> select Gradle -> Global Gradle Settings -> offline work

Amitabha Biswas
  • 3,281
  • 1
  • 11
  • 23
1

You can do a lot of things, One of them is disabling Crashlytics for debug flavor.
In build.gradle :

android {
  ...
  buildTypes {
    debug {
      ext.enableCrashlytics = false
    }
}

In the class where you initialised fabrics:

Crashlytics crashlyticsKit = new Crashlytics.Builder()
    .core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build())
    .build();

Fabric.with(this, crashlyticsKit);

Hope this helps.

Reference : https://developer.android.com/studio/build/optimize-your-build.html