See image below:
What exactly does the Sync now (blue) and refesh button (red) do respectively? What Gradle Tasks and/or other processes does Idea/Android Studio launche when clicking these?
I need to debug some errors with my gradle.build file and knowing what these buttons do will help me in that regard.
Both those actions do essentially the same thing. Their primary task is to evaluate the Gradle build files to synchronize Android Studio's picture of the structure of the project with the source of truth in the Gradle build files. It doesn't execute a specific task to do this, but it instead evaluates the build file, executing it up to the point before it would actually fire off any tasks. Gradle builds up an internal model of the state of the project, and it hands this model off to Android Studio, which then updates its notion of project structure to reflect any changes.
After this model evaluation process, which again doesn't invoke any specific tasks, Android Studio does execute the generateSources
task. This step creates any automatically generated source files, such as R.java, which need to be there for the IDE to provide proper syntax highlighting and content assist for doing normal development.
The fact that Android Studio will execute the build file at times other than doing an actual build is a reason why you have to be careful about knowing the execution context of any custom code you put in the build file, especially if that code does long-running or potentially destructive operations -- that code could be run at times you may not expect, more often than you expect.
来源:https://stackoverflow.com/questions/24080380/what-gradle-tasks-does-idea-android-studio-run-when-i-press-sync-now-and-the