Skip to content

Android: Using SVN with your app’s project (and eclipse)

by mat on February 11th, 2010

When creating any non-trivial program using a versioning system is essential, especially when working in part of a group. This guide aims to be a quick tutorial to the SVN (subversion) tool for versioning and how to use it with an android project.

Assumptions

  • You will need SVN installed on your computer. This can be done using your package manager or by the following command in ubuntu / debian based systems:

    sudo apt-get install subversion
  • You already have an SVN repository configured. If not please view a tutorial like this or if you have a nice webhost like me (thanks dreamhost :P ) there may be a simple tool to do this automatically for you in your panel.

Note
Don’t include the files inside /bin or /gen as they are just build from the source code and will simply fill up a lot space in your SVN. But do include the folders themselves as the project will fail to build without them.

Command line (recommended)
For SVN, I am a great fan of the command line. From the few SVN GUI applications that I have used in the past I can recommend Turtoise SVN for windows and kdesvn for linux (kde) but I still prefer the command line.

The following code will checkout the project from your server. This will create a new folder called “projectname” on your computer and download the project from your server (at this point it is most likely an empty folder).

# Checkout the SVN directory
svn co svn.yourdomain.com/projectname projectname

You can then copy or create your android project in this directory. In our project folder there are two folders which contain generated files (as opposed to source files) there is no point uploading these to the svn as you will simply take up space and bandwidth. Before you decided to upload your changes to the server you should empty the bin and gen folders:

# Empty bin and gen folders
rm -rf ./projectname/bin/*
rm -rf ./projectname/gen/*

Each time you add a new file to the project you will need to add (`svn add filename` for single files or `svn add *` for all files):

# Tell SVN we want to be versioning these files
svn add projectname/*

When you are happy with your changes you can commit (`svn commit -m “message”`) your changes to the svn to create a new version, it is mandatory to include a message with each revision and it is best to be as detailed as possible with the changes made. This makes it much easier to hunt down where a bug or regression was introduced.

# Save the changes and upload to repository
svn commit -m "Initial import of projectname"

Each time you commit or wish to upgrade what is stored locally to the latest version on the server you need to use the following:

# Update the locally stored version
svn update projectname

Further points
Eclipse has a plugin to manage SVN download and install instructions can be found here.

4 Comments
  1. Ben permalink

    I personally prefer working directly in the directory. That saves all the superfluous “projectname” arguments in your commands.

    for example:

    svn co http://myserver.com/projectname #this creates a directory called projectname on its own, only need to add the other argument if you want to
    cd projectname

    [after some local changes]
    svn ci -m “here are my changes” #ci = checkin, which is the same as commit

    [after some changes other people have made]
    svn update

    Before you check in, you might want to see what has changed:
    svn status
    this gives a listing of everything that’s changed recently.

  2. georgm permalink

    Don’t forget to set ignore property to gen and bin, either in these directories or in base directory

    in bin and gen:
    svn propset svn:ignore “*” .

    or

    svn propset svn:ignore “bin
    gen” .

  3. Henrik permalink

    A recent GUI for linux working much like tortuise is rabbitsvn. It’s by far the best SVN GUI I’ve tried.

Trackbacks & Pingbacks

  1. SVN commit error with Eclipse Indigo, Android with ADT-Plugin | PHP Developer Resource

Leave a Reply

Note: I am currently writing my thesis so probably wont have time to reply to your comment
Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS