Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force eclipse to update the apk on my hardware device with each build?

If I change some code, save, and Run, it runs the last version of the program, not what I just saved. The only way I can make it update is if I Clean the project, Build the project, and then Run the project. Is there some way to avoid this tedium?

like image 351
shino Avatar asked Jul 03 '12 04:07

shino


4 Answers

I spent some time create two dummy projects (one Android and one Java) and have a play with it, and finally come up with a workaround which is not used very often but able to solve your requirements.

First, I will explain your question a bit more (based on my understanding and what I have tried) so that other people can have a more clear understand about what is happened here.

According to the conversation in comments:

could you tell me what you have in following setting: project->properties->Builder ? – Sudar Nimalan

@SudarNimalan: I am not sure this is what you are asking, but: there's text that says "Configure the builders for this project", and under it is a single option, "Java builder", which is selected (checked). – shino

for android project, there should be, "Android Resource Manager", "Android Pre Compiler", "Java Builder", "Android Package Builder" in this order, chould you add those and try? – Sudar Nimalan

@SudarNimalan: I owe you an apology; I do have those four components. My "project" is split into 4 projects - "core", "core-android", "core-desktop", and "core-html". It's a little weird because I set it up with the libGDX project setup UI, and I was looking at the 'core' project when I answered your question. My 'core-android' project has all four (in that order), and it is the one that has the problem in my question. – shino

Scenario:

You have 4 project:

  • core: a regular java project (common pure java code here)
  • core-android: an Android application project.
  • core-desktop: not related to question so ignored.
  • core-html: not related to question so ignored.

The core-android project has dependency on core project, by adding core to core-android's build path (Properties -> Java Build Path -> Projects -> Add ...) and export list (Properties -> Java Build Path -> Order and Export).

Problem (Not Really):

Change some code in core and save it, run core-android, eclipse install last compiled apk, not the new one with change.

Reason:

The is the expected behavior, the way you used to reference core project in core-android only create a weak link (or something sort of) between core and core-android, the core-andorid's auto-build script doesn't aware any changes made in core. You have to clean the project (only need clean core-android project) so that Eclipse can delete the existing apk (under bin directory) and re-generate the apk (with the latest code changes from core).

See Xav's comments below, Android SDK tools should aware changes from plain Java project under project build path, and it does not behaviour this feature normally at the moment.

Note that if core is an Android Library project, then there is no problem and your core-android project will aware any changes in core project (java code, android resource and etc), if core is only used in core-android, this could also be a workaround: turn Java project core into Android library project.

Workaround (Eclipse Link Source):

There is another way (not commonly used) for adding soft link between projects:

  1. First, you need remove core project from core-android's build path, this will also remove it from Export and Order list.
  2. Right click core-android, choose Build Path -> Link Source ... Add ../core/src as Linked Folder Location and src-lib1 as Folder Name,see screen screen in the end.

This create a symbolic link src-lib1 under core-android in Package Explorer windows point to core's src foder, in the file system, you still have two separate project folder. Now if you change some code in core and run core-android, Eclipse will build and install latest apk. No need to clean core-android project.

Link Source Window: enter image description here

Final look in Package Explorer:

enter image description here

You should always consider the normal approach as first option, after all, manual clean project is not a big deal compare to the unusual approach I described above.

like image 74
yorkw Avatar answered Nov 07 '22 12:11

yorkw


Please follow this steps..

1. Project--> Build Automatically been checked??

2. Please following setting: project->properties->Builder like that?

Check below image.

enter image description here

And Also Check Below Settings.

enter image description here

Also Check Below Image

enter image description here

IF problem continues then please Update your ADT & SDK.

Hope it works for you .

like image 4
Nikhil Avatar answered Nov 07 '22 12:11

Nikhil


Navigate to Windows->Preferences->Android->Build. Make sure that the checkbox "Skip packaging and dexing..." is NOT checked.

like image 3
Bananeweizen Avatar answered Nov 07 '22 12:11

Bananeweizen


The Problem is the In your Eclipse, go to Project Properties - Builder, There is one CheckBox with AndroidPackageBuilder that is required to be Checked True. Now everytime you will do any changes in you project that will be reflected in your build and the Compiler will never say that "Application Already Deployed, No need to Reinstall"

This will work evenif you dont have selected Build Automatically, Because everytime you run by clicking Run icon or Ctrl+F11 that will first Build the Project and Then Run it. So The requirement is just to Enable the Android Package Builder

enter image description here

like image 3
MKJParekh Avatar answered Nov 07 '22 12:11

MKJParekh