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

android1

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!

 

Ryan Hayes

Ryan is a Microsoft MVP award winner with over eight years of software experience, working with big-name clients such as Discovery Channel, AOL, Toyota, and the National Academy of Sciences. Ryan has helped teams deliver award-winning applications that drive business processes, site traffic, and profit, putting his experience and creativity to work to build amazing solutions for the enterprise web, desktop and mobile platforms.

  • Tomas

    That saved my day. I’ve spent all morning trying to update everything to get rid of the “error 2″ problem and this simple solution fixed it. Thanks!

  • sathish android

    Hi all,
    Thanks for posting useful info above. Help to others was a great thinking.
    I was  working as an  android developer. I have experience on Java/J2ee with eclipse gelileo and SVN . But i don’t have minimum knowledge on TFS and how to work with TFS. Now in my company , i have to work on TFS with eclipse. So i installed TFS Plugins into eclipse successfully and i am able to see all the files and folder of TFS from my eclipse. But i don’t know how to check in and check out to/from TFS using this plugin in eclipse. So i am searching for some tutorials to work with TFS in eclipse.

    Can any one help me in this?
    Any help will be appreciated great.
    Thanks,
    Sathish.
     

  • Mark Edgeworth

    Hi all,
    Nice article, but for me this did not fix the problem.  What I needed was to remove the ‘-XX:+AggressiveOpts’ option from the list of start-up arguments passed to eclipse.  Worked a treat.
    Ta, hope this helps,
    Mark

    • X Ray

      Hi Mark, your trick helped me in my case. I was stuck with this error for a while and could not figure out what’s going on.

  • http://www.register-web-domain.in Register a domain

    It is really nice to hear your discussion on specific topic here. I too agree with your points here. keep posting good blogs. Thanks.

  • Btk

    Dude, thank you so much!!  This was exactly what I needed!