Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should I synchronize and when should I build / rebuild project in Android Studio and can I automate it?

What is the difference between the following actions in Android Studio and when should I use them?

  • Synchronize
  • Build project
  • Rebuild project

When do I use each one (after pull, after a change in xml file, after change in java file)

Which is mandatory before Run and can I make Run automatically do whatever is needed for me?

like image 209
Kaloyan Roussev Avatar asked Oct 31 '22 07:10

Kaloyan Roussev


1 Answers

There is no such thing like 'Build project' in Android Studio, there is 'Make project'. I'll cite the documentation here (Android Studio is based on the the IntelliJ IDEA, so don't be surprised by the words 'Intellij IDEA'):

IntelliJ IDEA suggests several ways of compiling and building applications. The corresponding commands are available in the Build menu.

  • Make Project. All the source files in the entire project that have been modified since the last compilation are compiled. Dependent source files, if appropriate, are also compiled. Additionally, the tasks tied to the compilation or make process on modified sources are performed. For example, EJB validation is performed if the corresponding option is enabled on the Validation page.
  • Rebuild Project. All the source files in the project are recompiled. This may be necessary when the classpath entries have changed, for example, SDKs or libraries being used added, removed or altered.

Clean is Gradle-related task, it clears the intermediate files in build directories. Essentially, Rebuild Project does Clean, followed by the full build of entire project - compiles your .java files, converts them into dex format, and so on.

Synchronize is also Gradle-related task, it's used to refresh dependencies after you've changed the content of your build files.

In short, if you've changed the content of your build files and/or changed some Java files, and/or changed some resources and want to run the updated version of application on your Android device/emulator, hit Shift+F10 - it'll update ('synchronize') your dependencies, make the project and run it on the device.

like image 196
aga Avatar answered Nov 08 '22 08:11

aga