Java Gradle 依赖项的解析突然变得非常缓慢
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22550761/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Gradle dependencies resolving suddenly extremely slow
提问by Emma
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.
我正在使用 Android Studio 和 gradle 开发 Android 项目。直到昨天,gradle build 在几秒钟内构建得相对较快。从今天开始,每个构建的时间突然变成了 5 分钟。
I gave bigger size on gradle VM but still has no hope.
我在 gradle VM 上提供了更大的尺寸,但仍然没有希望。
Could anyone give me any tips what is going on and how to solve this?
谁能给我任何提示发生了什么以及如何解决这个问题?
Android Studio: 0.4.6 Gradle: 1.9
Android Studio:0.4.6 摇篮:1.9
build.gradle
构建.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.+'
.....
}
采纳答案by Vanama
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]
我也有同样的问题,我联系了我的提供商,该提供商跟踪到 www.mvnrepository.com(依赖项的存储库),跟踪将在 ec2-79-125-0-137.eu-west-1.compute.amazonaws.com 结束[79.125.0.137]
Problem is on amazonaws.com. Here is trace route:
问题出在 amazonaws.com 上。这是跟踪路由:
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 ?asovy limit ?ádosti.
16 * * * Vypr?el ?asovy limit ?ádosti.
17 * * * Vypr?el ?asovy limit ?ádosti.
18 * * * Vypr?el ?asovy limit ?ádosti.
19 * * * Vypr?el ?asovy limit ?ádosti.
20 * * * Vypr?el ?asovy limit ?ádosti.
21 * * * Vypr?el ?asovy limit ?ádosti.
22 * * * Vypr?el ?asovy limit ?ádosti.
23 * * * Vypr?el ?asovy limit ?ádosti.
24 * * * Vypr?el ?asovy limit ?ádosti.
25 * * * Vypr?el ?asovy limit ?ádosti.
回答by Laimiux
If you are using Android Studio with gradle, for the time being doing
如果您正在使用带有 gradle 的 Android Studio,暂时这样做
go to android studio -> preferences -> compiler -> gradle -> check offline mode
转到 android studio -> 首选项 -> 编译器 -> gradle -> 检查离线模式
has improve my build times drastically. Since, I already have latest libraries cached it works
大大改善了我的构建时间。因为,我已经缓存了最新的库,它可以工作
well.
好。
回答by pawpaw
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)
对于找不到该设置的新手(Android studio 1.5.1)
文件 -> 设置 -> 构建、执行、部署 -> 构建工具 -> Gradle
最后一个复选框(离线工作)
and thanks a lot guys - from like 10 mins to 30sec
并感谢很多人 - 从大约 10 分钟到 30 秒
回答by CoolMind
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:
经过数小时的搜索,我发现代理设置和 gradle 选项在 Android Studio 1.5.1 中发生了变化。有关更多信息,请参阅http://www.laurivan.com/gradlew-and-proxy-authentication/。将 C:\Users\.gradle\ 中的 gradle.properties(全局属性)更改为以下内容:
# 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_
回答by Dr. Failov
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.
我遇到了同样的问题,花了很多时间才找到原因。正如我所注意到的,在offline mode
gradle 中构建速度要快得多。
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:
回答by Guthyerrz
My problem was my proxy settings. Our private maven repository url was failing an ssl check because of my Charles configuration.
我的问题是我的代理设置。由于我的 Charles 配置,我们的私有 Maven 存储库 url 未能通过 ssl 检查。
回答by Muhammad Omer
Its may be due to resolving Github maven dependencies as all other dependencies are being looked into your repository which takes time, you can filter your repository by only looking into your dependency by following native gralde support i.e
这可能是由于解决了 Github maven 依赖项,因为所有其他依赖项都在您的存储库中查看,这需要时间,您可以通过遵循本机 gralde 支持仅查看您的依赖项来过滤存储库,即
Repository to dependency matching
依赖匹配的存储库
It is now possible to match repositories to dependencies, so that Gradle doesn't search for a dependency in a repository if it's never going to be found there.
现在可以将存储库与依赖项进行匹配,这样 Gradle 就不会在存储库中搜索永远不会在那里找到的依赖项。
Example:
例子:
repositories {
maven {
url "https://repo.mycompany.com"
content {
includeGroupByRegex "com\.mycompany.*"
}
}
}
for further reference Gradle 5.1.1
进一步参考Gradle 5.1.1