什么是Android Studio中的Gradle同步? [英] What is gradle sync in Android Studio?

查看:341
本文介绍了什么是Android Studio中的Gradle同步?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是什么?它是做什么的? 我正在一家拥有代理的企业上工作,但尝试连接到某个地方失败. 为什么需要互联网连接?它使用什么端口?

What is it? And what does it do? I'm working on an enterprise that has a proxy, and it fails trying to connect to somewhere. Why does it needs internet connection? What ports does it use?

编辑:用户Caleb的回答很完美.我想补充一点,也应该在gradle.properties中配置代理.像这样:

The answer of the user Caleb was perfect. I would like to add that the proxy should be configured too in the gradle.properties. Something like this:

systemProp.http.proxyHost=*proxyAddress*

systemProp.http.proxyPort=*portNumber*

systemProp.https.proxyHost=*proxyAddress*

systemProp.https.proxyPort=*portNumber*

推荐答案

是什么?它是做什么的?

What is it? And what does it do?

Gradle sync 是一个gradle任务,它会检查build.gradle文件中列出的所有依赖项,并尝试下载指定的版本.

Gradle sync is a gradle task that looks through all of your dependencies listed in your build.gradle files and tries to download the specified version.

dependencies {
     compile '...your dependency...'
}

为什么需要互联网连接?它使用什么端口?

Why does it needs internet connection? What ports does it use?

它需要 Internet连接,因为它通常是从远程位置下载这些依赖项.您可以通过更改gradle.properties来定义其使用的端口. (请参见下文)

It requires an internet connection because it is usually downloading these dependencies from a remote location. You can define what ports it uses by changing your gradle.properties. (see below)

我正在一家拥有代理的企业上工作,但它尝试 连接到某个地方.

I'm working on an enterprise that has a proxy, and it fails trying to connect to somewhere.

您的工作代理可能阻止了此操作,您需要添加代理配置来解决问题.

Your work proxy may be blocking this and you'll need to add your proxy configuration to solve your issues.

进入:

文件->设置-> Android Studio首选项->外观和行为/系统设置/HTTP代理

File-->Settings--> Android Studio Preferences --> Appearance & Behavior / System Settings/ HTTP Proxy

并将您的代理配置网址更新为您的工作代理. (自动或手动,具体取决于您的设置).

and update your proxy configuration url to your work proxy. (automatic or manual depending on your setup).

注意:如果您使用命令行运行gradle构建,则可能需要通过gradle.properties文件更新代理设置.

NOTE: If you are using the command line to run your gradle build, you will probably need to update the proxy settings via your gradle.properties file.

全局属性文件位置:〜/.gradle/gradle.properties (如果有,请使用本地项目文件)

Global Properties File Location : ~/.gradle/gradle.properties (or use your local project file if you have one)

将代理设置添加到该文件:

Add proxy settings to this file:

HTTPS

systemProp.https.proxyHost=<proxy host>
systemProp.https.proxyPort=<your proxy port>
systemProp.https.nonProxyHosts=<your non-proxy host>
systemProp.https.proxyPassword=<your pw>

HTTP

systemProp.http.proxyHost=<proxy host>
systemProp.http.proxyPort=<your proxy port>
systemProp.http.nonProxyHosts=<your non-proxy host>
systemProp.http.proxyPassword=<your pw>


如果您绝对无法通过gradle获得Internet连接,则需要以其他方式下载依赖项,并在计算机或本地网络上本地引用它们.


If you absolutely cannot get an internet connection via gradle you'll need to download the dependencies another way and reference them locally on your computer or local network.

(请参见使用本地指南罐子)

(See this guide for using local jars)

这篇关于什么是Android Studio中的Gradle同步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆