David Radcliffe

Re-building Android apps in Eclipse

Today I ran into a weird problem. I was working on our android mobile app and I wanted to make sure the .apk file I sent to QA was the most recent version. So I just dropped into the /bin directory and deleted the .apk. I assumed that the next build would absolutely re-create it with the most recent version. Instead, Eclipse gave me the following error:

java.io.IOException: Unable to upload file: Local file doesn't exist.

I tried just about everything to get it to work. I turned off automatic building and tried building myself. Nothing seemed to work. Finally I found the clean project menu item and tried that. Nothing seemed to happen but when I tried running again after that it finally worked.

It seems that Eclipse must not replace the .apk file but instead attempts to open and edit the file. A bit weird – but I can deal with it. It also seems that Eclipse doesn’t actually check to see if the file exists before it attempts to open it. Only after a ‘clean’ command does Eclipse create the file.

My final solution to be 100% sure the apk is current:

  1. Manually delete the .apk file
  2. Run the clean command from Eclipse
  3. Run or debug the project

I hope this helps someone else!