Home > Android, eclipse, Java, svn > Eclipse + Android + SVN = fail

Eclipse + Android + SVN = fail

If you are developing a project in SVN (I’m sorry for your predicament) and using Eclipse, please heed my advice.  Otherwise you could unintentionally delete your source directory during a routine cleanup.

Now, how could you possibly do that? you might wonder.  Are you incompetent?  Well, maybe, but not in this case.  The situation was this: I was about to make a commit of some changes to the code and did a svn status before committing to ensure that everything was as I wanted it to be.  I noticed that there were dozens of files in the bin directory that either had question marks next to them (.class files) or showed up with exclamation points next to them (indicating that SVN thought they’d gone missing).  Given that the binary class files do not belong in version control, I went ahead and did a svn rm -rf bin (recursively delete all the files under bin).  I went ahead and finished the commit.  Later I went to make another commit and I got an error telling me that the src folder didn’t exist in the svn repository.  Horrified, I my unix history and then the svn commit log:

529  svn rm –force bin/
530  svn ci -m “Bin should not be under version control.”

Revision 249
Author:     ndunn
Date:   Mon Jul 26 14:52:14 2010 UTC (62 minutes, 34 seconds ago)
Log Message:

Bin should not be under version control.

trunk/projname/src/     deleted

Um.  What?  I’m pretty sure bin != src.  Well.  You’d think that.  But if you’re using Eclipse and haven’t dived in four menus deep, you’d be wrong.

You see, for some reason Eclipse copies all the files from the src folder into the bin folder when you build the project.  Why it does that, I’m not sure.  I’d love to know why.  Regardless of the reason, all of the files in the src are copied.  Including… the hidden .svn folders.  These folders are how subversion keeps track of the changes to your files.  The problem is, since the .svn folders were copied, and bin was deleted, it was exactly the same to svn as if I had deleted src.  Which is why my src folder disappeared.

How do you work around this?  Well, I mentioned earlier that by default eclipse copies all of the files from src to bin.  You can add filters so that certain files/extensions are ignored, if you know where to look.  In Eclipse, go to Preferences -> Java -> Building -> Output Folder and make sure that *.svn is on the line for filtered resources.  It will prompt you to rebuild your project.  Once it does so, you will not have this potential mistake looming over your head.

Finally, here’s the svn command you need to revert a folder if you accidentally delete it and check the deletion into source control.  Let’s assume you deleted the folder in revision n.  Then you want to fetch the status of that folder at n – 1

n = 249

svn  copy -r248 -m "Restore deleted trunk/src"  svn+ssh://username@company/path/to/trunk/src@248  svn+ssh://username@company/path/to/trunk/src

Thanks to the android developers group for helping me figure out what was going on; see here for details.

I have submitted a bug / feature enhancement request to the Eclipse developers so that the default behavior is a bit more sane.  You can find that bug report here. The commenters mention that installing the svn plugin for Eclipse fixes the problem, but I don’t think I or anyone else should have to install something just to have sensible behavior.

The StackOverflow post giving a shorter synopsis of the problem can be found here.


Lots of Android developers use Eclipse to develop their projects due to the plugin support available.  I’d wager a fair number of them use SVN as well for their source control.  They should be very wary about the default behavior of Eclipse, and ensure that they filter to remove .svn files from being copied over to their src folder.  Take it from me – it’s not a good feeling seeing a commit message with your name on it deleting the src folder.  Or you could use git and not have to worry about any of these problems…

Categories: Android, eclipse, Java, svn
  1. July 29, 2010 at 2:19 pm

    Uh, maybe I’m missing something here, but why aren’t you using the official SVN functionality (plugin) for Eclipse? That’s what nearly all eclipse users use. Your predicament is exactly what happens when you try to use a monolithic app that’s unaware of version control happening elsewhere (lots of Mac apps do similar nasty things, for example.) But that’s also exactly why the eclipse SVN plugin exists, and why everyone uses it… to exactly avoid this problem. 🙂

    • Nick
      July 29, 2010 at 2:28 pm

      Since I prefer working on command line when possible I never installed the svn plugin. I’m sure there exist people with the same software setup and I want to warn them about this behavior. It has happened to people at my work, for instance.

      If the plugin fixes it that’s great. But people should be aware of the problem


      • October 1, 2011 at 4:25 am

        You are right about other people with the same software setup. Command-line-addicted users are not extinct! 🙂

        Anyways, thanks a lot for your post! It _literally_ saved my day 😀


  2. zhoubig
    November 8, 2010 at 10:27 am

    this blog is definitely helpful

    • i82much
      November 8, 2010 at 11:15 am

      Thanks! My basic reason for writing any post is that I’ve struggled with something non-obvious for >= 15 minutes and decide to write up the solution to solving it for the next poor sap who comes along facing the same problem. No need to reinvent the wheel each time.

  3. Jake
    December 5, 2010 at 11:53 am

    Thanks so much. This post really helped me out.

    • i82much
      December 5, 2010 at 12:28 pm

      Glad it could be of some help.

  4. anant
    February 2, 2011 at 5:40 am

    is svn not compatible with any of the eclipse based android application

    • i82much
      February 2, 2011 at 7:21 am

      I don’t understand your question.

  5. Bull
    February 8, 2011 at 10:41 pm


  6. Binzi
    March 15, 2012 at 1:23 pm

    This issue of eclipse has wasted SO much of my time. The issue itself is just ridiculous. How is that important folders disappear? And I couldn’t agree more on this:
    “The commenters mention that installing the svn plugin for Eclipse fixes the problem, but I don’t think I or anyone else should have to install something just to have sensible behavior.”

    I feel like i need a punching bag beside me while working with Eclipse sometimes. It is a great IDE no doubt about that, but such simple things cause so much waste of time and frustration.

    • i82much
      March 15, 2012 at 1:43 pm

      Yup, I haven’t used Eclipse in awhile and I’ve been happier for it. Learning my way around emacs… Though I haven’t been doing as much Java development.

      I did try IntelliJ IDEA and it seemed much better than both Eclipse and Netbeans. Will write up my thoughts of it at some point if I use it more.

  1. July 28, 2010 at 11:49 pm
  2. May 24, 2012 at 11:05 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: