Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio 1.0 build too slow

I've updated Android Studio to 1.0 RC (both 1 and 2) from 0.9x and my project build time passed from 20 sec to around 90 sec.

Anyone is having the same problem?

UPDATE

Running the same task on terminal, I see that the "Resolving dependencies" step is taking most of the extra time.

UPDATE 2

Thanks to @bond, I've noticed that going offline lowers the build time to about 30 sec, so I tried to use mavenLocal() on the build.gradle, but no luck there either.

Top Level build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        mavenLocal()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
    }
}
like image 785
Cheborra Avatar asked Nov 27 '14 17:11

Cheborra


People also ask

Why is Android Studio running so slow?

There may be many plugins in Android Studio that you are not using it. Disabling it will free up some space and reduce complex processes. To do so, Open Preferences >> Plugins and Disable the plugins you are not using.

How do I fix lag on Android Studio?

Android Studio needs at least 8 GB RAM to run better. Change your Hard Disk to SSD. Loading/Compiling/Designing/Writing time will be reduced even in 4GB RAM. Use Power Save mode from File Menu that will reduce lots of background work.

Why is my Gradle build so slow?

This happens due to the fact that the module needs to be built from the scratch every time. Enable gradle Offline Work from Preferences-> Build, Execution, Deployment-> Build Tools-> Gradle. This will not allow the gradle to access the network during build and force it to resolve the dependencies from the cache itself.


3 Answers

In compiler settings (Android Studio -> Preferences -> Project settings[your project] -> Compiler (Gradle-based Android Projects)), type --offline in the "Command-line options" box.

from ~4 minutes to ~20 seconds.

like image 93
whoKnows Avatar answered Oct 17 '22 23:10

whoKnows


I ended up building the first time online, and after that switching to offline mode

Gradle Options

That lowered the time to ~14 secs.

My guess is that gradle is trying to resolve dependencies online ignoring my "mavenLocal()" (and all its variants)

like image 29
Cheborra Avatar answered Oct 17 '22 22:10

Cheborra


For Newcomers, who can't find Gradle Offline settings (Android studio 1.5.1)
File -> Settings -> Build,execution, deployment -> Build tools -> Gradle
last checkbox (Offline work)

and thanks a lot guys - from like 10 mins to 30sec

like image 1
pawpaw Avatar answered Oct 17 '22 23:10

pawpaw