Gradle dependencies resolving suddenly extremely s

2019-02-02 06:16发布

问题:

I am developing Android project with Android Studio and gradle. Till yesterday, gradle build was building relatively fast in a few seconds. Since today, it suddenly became 5 minutes per build.

I gave bigger size on gradle VM but still has no hope.

Could anyone give me any tips what is going on and how to solve this?

Android Studio: 0.4.6 Gradle: 1.9

build.gradle

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.7.3+'
    }
}

apply plugin: 'android'

repositories {
    maven {
        url 'https://github.com/Goddchen/mvn-repo/raw/master/'
    }
    mavenCentral()
}

dependencies {
    compile 'com.android:volley:1.0'
    compile 'com.android.support:support-v13:13.0.+'
                .....
}

回答1:

I have same problem too and i contacted my provider which tracked trace to www.mvnrepository.com (repository for dependencies) and trace will end on ec2-79-125-0-137.eu-west-1.compute.amazonaws.com [79.125.0.137]

Problem is on amazonaws.com. Here is trace route:

1 < 1 ms < 1 ms < 1 ms private.rionet.cz [172.25.20.1]
2 10 ms 10 ms 9 ms private.rionet.cz [172.28.0.1]
3 11 ms 10 ms 10 ms rio-bb-jsw01-vlan-4050-94-74-192-164.net.rionet.
cz [94.74.192.164]
4 11 ms 10 ms 10 ms sitK9-bb-jsw01-xe-0-1-2-0-188-175-255-85.net.rio
net.cz [188.175.255.85]
5 10 ms 9 ms 10 ms sitK9-bb-jrt01-xe-9-0-0-0-188-175-255-197.net.ri
onet.cz [188.175.255.197]
6 68 ms 10 ms 9 ms prag-b3-link.telia.net [213.248.87.97]
7 15 ms 17 ms 17 ms win-bb2-link.telia.net [213.155.131.68]
8 34 ms 34 ms 34 ms hbg-bb2-link.telia.net [62.115.136.30]
9 92 ms 154 ms 47 ms ldn-bb2-link.telia.net [80.91.247.169]
10 65 ms 64 ms 85 ms dln-b1-link.telia.net [213.155.136.121]
11 70 ms 55 ms 64 ms amazon-ic-300342-dln-b1.c.telia.net [80.239.128.
18]
12 65 ms 64 ms 64 ms 178.236.0.126
13 64 ms 71 ms 64 ms 178.236.0.125
14 66 ms 57 ms 57 ms ec2-79-125-0-137.eu-west-1.compute.amazonaws.com
[79.125.0.137]
15 * * * Vypršel časový limit žádosti.
16 * * * Vypršel časový limit žádosti.
17 * * * Vypršel časový limit žádosti.
18 * * * Vypršel časový limit žádosti.
19 * * * Vypršel časový limit žádosti.
20 * * * Vypršel časový limit žádosti.
21 * * * Vypršel časový limit žádosti.
22 * * * Vypršel časový limit žádosti.
23 * * * Vypršel časový limit žádosti.
24 * * * Vypršel časový limit žádosti.
25 * * * Vypršel časový limit žádosti.


回答2:

If you are using Android Studio with gradle, for the time being doing

go to android studio -> preferences -> compiler -> gradle -> check offline mode

has improve my build times drastically. Since, I already have latest libraries cached it works

well.



回答3:

For Newcomers, who can't find that 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



回答4:

After many hours of searching I found that proxy settings and gradle options have changed in Android Studio 1.5.1. See http://www.laurivan.com/gradlew-and-proxy-authentication/ for more information. Change gradle.properties (Global properties) that lies in C:\Users\.gradle\ to following:

# Speedup
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=true
# Speedup and proxy settings
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError \
-Dfile.encoding=UTF-8 -Dhttp.proxyHost=xxx.xxx.xxx.xxx -Dhttp.proxyPort=pppp \
-Dhttps.proxyHost=xxx.xxx.xxx.xxx -Dhttps.proxyPort=pppp \
-Dhttp.proxyUser=_username_ -Dhttp.proxyPassword=_password_


回答5:

I had the same problem, and spent a lot of time to find the reason. As I noticed, in offline mode gradle builds significantly faster.

After few days of research I found, that reason was incorrect repository in project settings. In my case it was

http://clinker.47deg.com/nexus/content/groups/public

The solution is delete incorrect repository in project settings:



回答6:

My problem was my proxy settings. Our private maven repository url was failing an ssl check because of my Charles configuration.