Android build gradle is too slow (Dependency Resolution)
<p>I've been working with Android Studio (my current version 1.5) for 2 years. Everything was OK, but when I downloaded Canary (2.1 p5), everything went wrong. Every time I want to create a new project or open a project or sync or import a new lib or dependency, gradle is taking too long to build &mdash; <strong>nearly 20 min</strong>.</p>

<p>I did not do anything, I just downloaded the Canary version and ran it.</p>

<p><strong>Symptoms :</strong></p>

<ol>
<li>It happened when I connected to Internet</li>
<li>The first delay is on <em>Gradle: Resolve dependencies ':app:_debugCompile'</em></li>
<li>...</li>
<li>After 25 min building almost done</li>
</ol>

<p><strong>Note</strong>:
<em>When I disconnect my Internet, gradle will finish as fast as possible</em></p>

<hr>

<p><strong>I tried to fix this by these ways</strong>:</p>

<ol>
<li>I changed the gradle to offline work (it worked but I don't want this way, because I want to import libs or dependencies)</li>
<li><p>I've created a new file (file name is <code>gradle.properties</code>) in <code>C:\Users\username\.gradle</code> then wrote these lines into it</p>

<pre><code>org.gradle.parallel=true
org.gradle.daemon=true
</code></pre></li>
<li><p>I removed that version then installed my old version which worked OK but the problem was still there :( </p></li>
<li><p>Disable / Enable firewall</p></li>
<li><p>Disable / Enable AntiVirus (Nod32)</p></li>
<li><p>Reinstall Windows OS (8.1)</p></li>
<li><p>I've downloaded all versions (1.0.0, ..., 1.5.1, 2.0.0, 2.1)</p></li>
<li><p>I've used a proxy</p></li>
</ol>

<hr>

<p><strong>System info</strong>:</p>

<ul>
<li>CPU: Intel Core i5</li>
<li>Ram: 6.00 GB</li>
<li>OS: Windows 8.1 64 bit</li>
</ul>

<hr>

<p><strong>build.gradle(Project:appName)</strong></p>

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

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

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

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
</code></pre>

<p><strong>gradle.build(Module:app)</strong></p>

<pre><code>apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.example.test.myapplication"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.3.0'
}
</code></pre>

<p><strong>Gradle report after building</strong></p>

<pre><code>Dependencies                  Duration
All dependencies              14m3.43s
:app:_releaseCompile          3m30.96s
:app:_debugCompile            3m30.73s
:app:_debugApk                3m30.69s
:app:_releaseApk              3m30.62s
:classpath                    0.428s
:app:_debugAndroidTestCompile 0.001s
:app:_debugAndroidTestApk     0s
:app:_debugUnitTestApk        0s
:app:_debugUnitTestCompile    0s
:app:_releaseUnitTestApk      0s
:app:_releaseUnitTestCompile  0s
:app:releaseWearApp           0s
:app:wearApp                  0s
</code></pre>

<p><strong>After installing android studio 2.0 stable version</strong></p>

<ul>
<li>7:23:47 PM Gradle sync started ====>
8:13:21 PM Gradle sync completed</li>
</ul>