Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Increase Speed of Android Studio Application Builds?

Is there any way to display which process of my build is the one taking the most time and then try and work around it?

I am using Android Studio. I wouldn't call my project big at the moment but I guess the dependencies I require makes it larger and the build still takes between 40-60 seconds. (down from 90 seconds before removing multi dex)

Here are my Mid 2015 Macbook Pro's specs:

  • Processor: 2.5 GHz Intel Core i7
  • Memory: 16GB 1600 MHz DDR3

I have had to remove part of a dependency to be able to build without enabling multi dex support and this saved me ~20 seconds, however I want to add more dependencies so I need to improve my build time so I can then re-enable multi dex and actually use the dependencies I want to.

I have seen a few posts about modifying Android Studio to speed up the build time but these don't seem to have worked and I would rather see if I could fix the cause.

Here are my current dependencies:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

// MY INTERNAL LIBRARIES
    wearApp project(':wear')
    compile project(':ViewPagerIndicator')
    compile project(':connection-manager')
    compile project(':core-library')
    compile project(':activity-manager')
    compile project(':activity-recorder')

    compile 'com.google.android.gms:play-services-maps:7.5.0'
    compile 'com.google.android.gms:play-services-wearable:7.5.0'
    compile 'com.google.android.gms:play-services-location:7.5.0'

    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.android.support:design:22.2.1'
    compile 'com.android.support:cardview-v7:22.2.1'
    compile 'com.android.support:recyclerview-v7:22.2.1'
    compile 'com.android.support:support-annotations:22.2.1'

    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'joda-time:joda-time:2.7'
    compile 'com.androidplot:androidplot-core:0.6.1'

    compile project(':ParseLoginUI')

    /*Images*/
    compile 'com.squareup.picasso:picasso:2.3.3'
    compile 'com.makeramen:roundedimageview:2.1.0' // https://github.com/vinc3m1/RoundedImageView
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'io.reactivex:rxandroid:1.0.1'

//    apt 'com.google.dagger:dagger-compiler:2.0'

}
like image 576
StuStirling Avatar asked Aug 13 '15 17:08

StuStirling


1 Answers

There are two main things you can do improve building speed:

  1. Offline work:

offline work on gradle

  1. Compile against bigger SDK versions:

This one is tricky. Usually your minSdkVersion needs to be something like 14 or 16. This slow things down. If you compile using minSdkVerison = 22 speed times increase dramatically. You can increase minSdkVersion during development and reduce it when release.

like image 111
lgvalle Avatar answered Sep 22 '22 21:09

lgvalle