19

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()
    }
}
Cheborra
  • 2,627
  • 4
  • 23
  • 39
  • "and my project build time passed from 20 sec to around 90 sec" -- what were you using to build for the "20 sec" scenario? In other words, what are we comparing AS 1.0RC to? An earlier version of Android Studio? Eclipse? Command-line Gradle for Android? Ant? IntelliJ IDEA? NetBeans? Something else? – CommonsWare Nov 27 '14 at 17:50
  • Do you have Make Project Automatically under the Preferences -> Compiler (Gradle) tab? – MLProgrammer-CiM Nov 27 '14 at 18:03
  • you probably need better CPU and more RAM, I have 8 GB RAM at work in my dev machine otherwise it'd be an atrocity (hence why I used ADT instead in the past) – EpicPandaForce Nov 27 '14 at 20:34
  • Might be some configuration issue. Have you tried [resetting Android Studio](http://stackoverflow.com/questions/19384033/how-to-reset-android-studio)? – free3dom Nov 28 '14 at 08:24

6 Answers6

32

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.

whoKnows
  • 905
  • 2
  • 9
  • 27
29

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)

Cheborra
  • 2,627
  • 4
  • 23
  • 39
1

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

pawpaw
  • 145
  • 1
  • 2
  • 11
0

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
KulArtist
  • 965
  • 8
  • 20
  • 1
    I already do all of those, also, my dev behaviour didn't change from AS 0.9x to 1.x – Cheborra Nov 27 '14 at 19:25
  • Tell me your system configuration – KulArtist Nov 27 '14 at 19:27
  • 1
    Actually a hardware-accelerated emulator could be way faster than a normal mobile device. Also could upload large APK faster than the slow USB of the device. But running emulator on machine with just 4GB RAM could lead to lots of swapping and degrage performance. – WindRider Feb 18 '15 at 10:27
0

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.)

bond
  • 11,236
  • 7
  • 48
  • 62
  • ok, you did point me in the right direction, but no solution found yet... Going offline lowers the build time to ~20 sec... but calling mavenLocal() first on the build script does not make any difference. See update 2 above – Cheborra Jan 02 '15 at 14:15
  • @Cheborra, did you see anything on the gradle console after you turned on the stacktrace and debug options? (Can you post your repositories section and dependencies section from ur build gradle file?) – bond Jan 02 '15 at 15:06
  • Nothing worth mentioning – Cheborra Jan 02 '15 at 15:07
  • Try this one>> maven { url 'http://repo1.maven.org/maven2' } mavenLocal() mavenCentral() – bond Jan 02 '15 at 15:11
  • Another thing to note is what do you have on ur build.gradle on the top level one (not in ur module but the level up). – bond Jan 02 '15 at 15:13
  • The one published is the top-level one – Cheborra Jan 02 '15 at 15:14
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/68086/discussion-between-bond-and-cheborra). – bond Jan 02 '15 at 15:18
  • can you post one in the module too? how many modules do you have? (app, wear, tv?) – bond Jan 02 '15 at 15:19
  • only one module, 4 buildTypes and 2 Flavors tough... lets continue on chat – Cheborra Jan 02 '15 at 15:22
0

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
MChaker
  • 2,610
  • 2
  • 22
  • 38