What is gradle sync in Android Studio?

两盒软妹~` 提交于 2020-01-22 13:37:45

问题


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?

EDIT: 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*


回答1:


What is it? And what does it do?

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?

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.

Go into:

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

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.

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>

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)




回答2:


It needs internet connection to download dependencies



来源:https://stackoverflow.com/questions/43636707/what-is-gradle-sync-in-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!