Make Eclipse Clean and Rebuild an Android .apk When any Project File is Changed
Eclipse’s default behavior for an Android project seems to ignore changes to project files that aren’t handled by a Builder.
For example, an Eclipse project might have a text file with configuration data referenced in Project Explorer. By default, Eclipse will NOT rebuild and upload the .apk file upon modifying that file and Running or Debugging the project. Instead, the console shows:
[2011-11-21 21:51:25 - MyProject] Application already deployed. No need to reinstall.
This is also the default behavior of Eclipse with the Android Native Development Kit (NDK). Although running ndk-build creates new native C or C++ libraries, Eclipse does not rebuild and upload the .apk file upon using Run and Debug functions. Instead, it launches the old .apk file that already exists on the Android device.
The simplest solution is to enable the following option: Window | Preferences | General | Workspace | Refresh automatically. This causes Eclipse to automatically detect a change to a file referenced in Eclipse Project Explorer and Cleans, rebuilds and uploads the .apk file appropriately. I found I need to wait just a few seconds after saving the file before pressing F11 to launch Eclipse’s debugger.
This is saving me a lot of time in the build cycle.
Leave a Reply