Android: Using SVN with your app’s project (and eclipse)
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.
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 ) there may be a simple tool to do this automatically for you in your panel.
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
Eclipse has a plugin to manage SVN download and install instructions can be found here.