Articles Software

"Conversion to Dalvik format failed with error 2" with Android and the Team Foundation Server 2010 Eclipse Plugin

Recently I’ve been working on an big Android application where I work set for release later this year.  It’s going to be a great help to employees and distributors in the field letting them do all sorts of things they normally need to be at a computer for.  I’m using my Macbook Pro to do development as it’s easier to not have to switch back and forth from OSX to windows as I’m building application features in parallel in an effort to release simultaneously (which may or may not be smart).  One thing, though is that we use Microsoft’s Team Foundation Server at work, which is, of course, a Microsoft product.  Luckily they bought TeamPrise somewhere along the line and now there’s a great Eclipse plugin (unfortunately and frustratingly, only available to Bizspark or MSDN Ultimate subscribers – license key required upon install) to let you check in/out right from within Eclipse.  However, I had one problem that I couldn’t seem to figure out until I accidentally seemed to find something that works…

Upon installing the TFS Eclipse plugin and adding a project to source control, you’ll likely come across this error:

“Conversion to Dalvik format failed with error 2”

Something about the way files are added to TFS causes this error to happen initially, and no amount debugging the code will help at all (just to save you some time).  Here’s what worked and is the #1 thing to try according to my old pal who taught me how to code Java well in the first place – Drew Stockdreher.

In Eclipse’s menu:

  1. Select Project
  2. Select Clean…
  3. Profit! (or continue in what you were doing because you don’t need a step 3).

That’s it to fix this little error.  Now, I’m not saying this error doesn’t represent multiple different states, because exceptions can certainly do that to you sometimes.  However, if you’re getting started with TFS and Android in particular, give this trick a try whenever you come across it to rule it out as it literally almost takes no time at all.

Did this not help you out?  Did you find that “Conversion to Dalvik format failed with error 2” means something else?  Leave a comment and let everyone know!