Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get verbose messages of gradle sync?

Tags:

android

gradle

I have a multi-module (>20) project in Android Studio. The problem which I am facing is that whenever there in some change in build.gradle file of any module or if a new module is added, Android Studio asks for gradle sync which takes insanely high time (~12-15 minutes) and memory (order of 5GB). I want to know why what is causing this? Is there a way to find out what happens during gradle sync? Is there a terminal command to run gradle sync? Please help!

like image 774
Bhoot Avatar asked Sep 06 '25 06:09

Bhoot


1 Answers

I have been trying to figure out what actually happens during a gradle sync and how one can improve gradle sync timings. I am summarizing what I have found in this answer.

  1. Gradle sync is an Android Studio feature. Its sole purpose is to update the project model in Android Studio with respect to the build.gradle files in the project. For example, you might notice that a newly created module in your app is shown as a directory, but after gradle sync (assuming you have appropriate build.gradle for that module which points towards java sources, tests, resources etc.) the module is shown as a library (with a icon on your module's directory) in Android Studio. You may refer to helpful answer here.
  2. In a project which has large number of modules, you might notice that the gradle sync process consumes a lot of time and memory. I do not completely understand the reason behind this, but changing the vmstudio.options file to following configuration has helped me improve the gradle sync time to some extent:

-Xms512m
-Xmx4g
-XX:MaxPermSize=2g
-XX:ReservedCodeCacheSize=512m
-XX:+UseCompressedOops

I hope this is useful!

like image 159
Bhoot Avatar answered Sep 07 '25 20:09

Bhoot