Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to force Eclipse to automatically clean every run?

I am developing for Android and use Eclipse to create an apk that also has a .so file with C++ code in it. My problem is that when I only change the C++ code and recompile that outside of Eclipse, Eclipse doesn't really always see that it's changed and I have to clean the project and rebuild it before I can reliably start it. This behaviour has cost me lots of time because Eclipse is not using the new .so file.

Is there a way to force Eclipse to always rebuild the project before its being run ?

like image 381
HardCoder Avatar asked Feb 25 '12 02:02

HardCoder


People also ask

What is clean build in Eclipse?

It removes whatever already-compiled files are in your project so that you can do a complete fresh rebuild.

How do you're build the project in Eclipse?

Note that with Project > Build Automatically enabled, doing a Project > Clean... / Build Clean will automatically trigger a full rebuild. You will see a Building workspace job if you open the Progress view (Window > Show View > Other > Progress).


2 Answers

In Project Options, go to "C/C++ Build.

Select "Builder Settings" tab.

Uncheck "Use default build command" and in the field Build command, just add the target "clean" as the first target.

E.g. assuming you have

> make -j2 settings

change it to

> make clean -j2 settings
like image 58
rafamart Avatar answered Nov 08 '22 10:11

rafamart


I'm not sure how familiar you are with ant, but if you are compiling your c++ files through command line, one thought is to create an ant build script that will:

  • recompile your c++ files
  • clean and build your apk
  • install your apk onto your device

Then you can be sure the generated apk is always built using the latest compiled code.

like image 30
triad Avatar answered Nov 08 '22 10:11

triad