Android Studio How to Run Gradle Sync Manually

Android Studio how to run gradle sync manually?

Android studio should have this button in the toolbar marked "Sync project with Gradle Files"Sample Image

EDIT: I don't know when it was changed but it now looks like this:

Sample Image

EDIT: This is what it looks like on 3.3.1
Sample Image
OR by going to File -> Sync Project with Gradle Files from the menubar.

re-sync Gradle using Command line

It shall work without doing gradle sync.
do run command 'gradlew tasks' to see list of 'Build Tasks'; new flavor shall be listed as 'assembleflavor1' or 'assembleflavor2'.

how to sync gradle with terminal

With command line in your root project

./gradlew build

It will sync and build your app

To see all available gradle task, use ./gradlew tasks

Where is a Sync project with gradle files button in Android Studio 3?

In Android Studio 3.3 it is here:

Sample Image

Syncing Android Studio project with Gradle files

EDIT

Starting with Android Studio 3.1, you should go to:

File -> Sync Project with Gradle Files


OLD

Clicking the button 'Sync Project With Gradle Files' should do the trick:

Tools -> Android -> Sync Project with Gradle Files

If that fails, try running 'Rebuild project':

Build -> Rebuild Project

What is gradle sync in Android Studio?

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)



Related Topics



Leave a reply



Submit