protld
protld

Reputation: 440

Set the startup configuration of Gradle syncing

I started using Android Studio just yesterday, when I created my first project it started to do the Gradle building.

I thought it was going to be only an one time process for each project.

But that's really annoying, it always do "Gradle Refreshing" and "Gradle Syncing" on each task I do.

I only agree that it should do Gradle Building once I try to build my application, but not all the time.

The causes which take place once Gradle Syncing is running:

and I have to wait until it finish (which usually take up to 1 minute), so I can do anything to my project.

Based on an answer here -> https://stackoverflow.com/a/35878520/6486232 - I followed what the user said, but my project is destroyed now (I think it was doing something important and I forced it..)

So I hope there's any configuration to do to not even start the Gradle Syncing task until I build the application.

Thanks!

Upvotes: 1

Views: 950

Answers (3)

usamember
usamember

Reputation: 488

You might have noticed thats the gradle process is taking more time when you are connected to the internet

have you tried downloading the full gradle package ? https://services.gradle.org/distributions/gradle-2.14.1-all.zip

it might be missing and thats why its taking time on trying to get it

1- open up the 'Terminal' tab of your Android Studio

2- type

gradlew

it should start the 63mb file download now ! keep the terminal box up and don't close it

edit- after that type gradlew --stop in the terminal

Upvotes: 2

protld
protld

Reputation: 440

The answer is here.

Thanks to @usamember - I understood him wrongly.

BIG EDIT: To stop the Gradle sync on Android Studio startup -> https://stackoverflow.com/a/39400099/6486232 But to stop it while using Android Studio, complete reading this answer.

@usamember meant to download the Gradle Terminal files first, and that can be done by typing the command which he provided, gradlew

It took 15 minutes for me to finish, (it depends on your internet connection).

Now you can easily type gradlew --stop

The result was:

F:\AndroidStudioProjects\RodentsMobile\RodentsMobile>gradlew --stop
Downloading https://services.gradle.org/distributions/gradle-2.14.1-all.zip
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
..............................................................................................................................
Unzipping C:\Users\HP\.gradle\wrapper\dists\gradle-2.14.1-all\8bnwg5hd3w55iofp58khbp6yv\gradle-2.14.1-all.zip to C:\Users\HP\.gradle\
wrapper\dists\gradle-2.14.1-all\8bnwg5hd3w55iofp58khbp6yv
Stopping daemon(s).
Gradle daemon stopped.
F:\AndroidStudioProjects\RodentsMobile\RodentsMobile>M`O^\MaO^ZMaO^\MaO^^MaO MaO"MaO%MaO&MaO'MaO'MaO'M`f^YM`f
'M`OMaO' is not recognized as an internal or external command,
operable program or batch file.

Here is the success info:

Stopping daemon(s).
Gradle daemon stopped.

Starting Gradle daemon back is more simple.

  • Type gradlew or gradlew --daemon in the Terminal

EDIT: Another way of starting Gradle back without errors, is trying to build your Android application.

  • If you got an error like that:
FAILURE: Build failed with an exception.

 What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 1572864KB object heap


 Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Then start Android Studio as Administrator and type gradlew or gradlew --daemon again.

EDIT: Another way of starting Gradle back without errors, is trying to build your Android application.

Upvotes: 2

Aleksandar G
Aleksandar G

Reputation: 1181

Try to check is there checked option (Sync project with gradle before building, if needed) in your settings, and if it is, uncheck it. Settings -> Build, Execution, Deployment -> Compiler -> Sync project with gradle before building, if needed. I hope it will help you.

Upvotes: 1

Related Questions