Android Studio : auto build like Eclipse

I decided to use Android Studio after using Eclipse since years. But I found one bad thing about Android Studio for me. Indeed, it seems it's not possible to have the auto build feature like in Eclipse. When files are modified and saved, I can't see if my project has errors, warnings, etc..

So is there any way to enable this ?


Solution 1:

IntelliJ (Android Studio) has a whole different build system to eclipse. It has incremental compiling that is different.

IntelliJ will tell you if something has an error / warning the the CURRENT open file.

So short answer no you can't. You will see the errors as you open the files, you can select "rebuild project" from the menu which will show you these errors. You can also enable "auto-import" for Gradle that may help.

You don't want to be doing 'rebuild project' all the time. So I'd recommend getting used to it.

Also you shouldn't rely on compile errors for coding, you should safely refactor and it should be a surprise when something pop's up a compile warning and you have to fix it.


You should read the IntelliJ FAQ

Q: What happened to incremental compilation? How do I compile my project?

A: It's there, but works slightly other way. By default IntelliJ IDEA compiles files only when it's needed (when you run your app or explicily invoke the Make action), and so saves system resources for other tasks that can be more important at the moment. The compilation is incremental: IntelliJ IDEA keeps track of dependencies between source files and recompiles only if a file has been changed.

Files with compilation errors are highlighted, and so are the folders containing them — so you can easily analyze them via Project view. To see a list of all files with compilation errors, select Scope | Problems from the View As combobox of the Project view. After each compilation, IntelliJ IDEA constantly performs background code analysis on files with errors, and removes the red highlighting automatically when you've fixed them.

To enable compiling files on every save, you can use the EclipseMode plugin: http://plugins.jetbrains.com/plugin/?id=3822 (third-party development, not bundled).

To be able to run code with errors, you can select the Eclipse compiler in Settings dialog, Compiler, Java Compiler and add the -proceedOnError option to the Additional command line parameters for the compiler.

http://www.jetbrains.com/idea/documentation/migration_faq.html

Solution 2:

To enable auto build you can follow next steps: click on Android Studio/Preferences/Compiler and turn on the Make project automatically option. enter image description here This will work for all projects imported in Android Studio.

If you want the option only on some projects: go to Run/Edit configurations and add the Make option in its Before launch task list.enter image description here