What's brewing in the mobile world?

Ignoring Android Files With Subversion

While setting up a new project for Android is fairly simple, checking things into Subversion can get a little tricky to downright annoying if you don’t do it right! One problem which I’ll talk about here is having to deal with seemingly random files making their way into the repository which constantly update themselves and change. If you check these files, the checkout will you will constantly be wrangling with yourself and other developers on your your team, wasting bandwidth and storage space, causing unnecessary conflicts, and just generally causing trouble. The core of the problem is that the files and directories we’re about to discuss are build, resource, or local settings files which will always get updated to run on each developer’s environment.

The following five entries need to be made into a properties file Subversion uses to ignore certain file patterns:

  • .classpath
  • .project
  • .settings
  • bin
  • gen

The following command, svn propedit svn:ignore will be helpful. The second part starts the editor, the third starts it regarding the ignore properties, and the last part tell you where to ignore the files. Period means “this” directory and all of its children. Each entry in this file will essentially be matches. Entries with a period are file types whereas entries without any are directories and their children. Each of these entries must be entered to prevent things like adding paths, libraries, or even just cleaning, refreshing, and running a build of your Android application.

For an Android project the period in the previously mentioned command should be wherever your manifest, the root of the project, is. It can also be a path so something such as app/ (or wherever your application resides). Since all we care about is the crazy things Eclipse and Android generate you want to keep the ignore inside that directory. Each entry is one line inside this file.

After you are done adding the five entries above to your ignore file, save it and check it in. A properly set up project will always show nothing after running an svn status regardless of settings, path, or local changes to the project which would alter the generated or build files but not the source.

Already Checked In

If you are correcting a broken check in because someone checked in any of these files, make sure you exit Eclipse first. Otherwise, it will constantly regenerate and update local copies of the files. You’ll have to make sure your local copies are up to date with no local changes to the repository. Then follow the above steps finishing with an svn remove of the offending paths and file types. Once it is all checked in you should be able to check out and use a clean version of your application.

Using a properly set up repository if you are checking out someone else’s project they’ve checked in without runtime garbage will mean you’ll want to create a new Android project and then select Create project from existing source when starting a new project in Eclipse. Fill in the application name box and navigate to the appropriate application path where the manifest resides. Once you’ve added JARs, external libraries, and/or whatever your application uses a quick refresh and build of your project will generate all the necessary files and you’ll be up and running.

Reference: http://www.petefreitag.com/item/662.cfm

Comments are closed.