gradle – Android Studio 1.0 build too slow-ThrowExceptions

Exception or error:

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()
    }
}
How to solve:

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.

###

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)

###

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

###

You can speed up your Android Studio performance and build time, you just follow these:

  • Use/open single project at a time
  • clean your project after running your app in emulator every time
  • use mobile/external device instead of emulator
  • don’t close emulator after using once, use same emulator for running app each time

###

Are you behind corporate firewall? You might want to try the following:
1. Go to Settings> Compiler(Gradle-Based Android Projects)
2. Command-line Options: put “–stacktrace –debug”
3. Build your project
4. Look at “Gradle Console” (Bottom right side of AS)

This might tell you where it is stuck.
Note: Gradle goes to repositories in order it is defined in build.gradle, make sure you have correct order (go to internal first, and fall back to other etc.)

###

Create a gradle.properties file in the following directory:

  • home//.gradle/ (Linux)
  • /Users//.gradle/ (Mac)
  • C:\Users\.gradle (Windows)

And add this line to the file:

org.gradle.daemon=true

Leave a Reply

Your email address will not be published. Required fields are marked *