Working Towards the Middle

Following on from the last post: I had a brand new Android application that used the Mono.Facebook library. I also had a sample application from Xamarin doing the same. Mine didn’t work. The sample did. I was getting the NoClassDefFoundError.

I had no idea how to go about working out the cause of the problem. Googling for answers didn’t seem to find anything.

So my tactic was to take a copy of the working project, and slowly comment things out to try to get it to look like my application that didn’t work.

This plan worked very well. I managed to comment out pretty much the entire application, eliminating all sorts of potential causes along the way until I eventually had barely any code left. But still the same worked and mine didn’t. But it was much easier to diagnose now. Something was different and there were almost no candidates left.

Surely it can’t be the namespace…? My app package was called FB2. The sample package was called So I changed the name of my app, and would you believe it…

So if you get an error that says:

Unhandled Exception:


… what it’s trying to tell you is that it is looking for the generated “R” class in the “” namespace.

Obviously, now that I’ve diagnosed the source of the problem, I could search for a more appropriate solution. Here’s a StackOverflow post about this very problem. If I decipher the solution posted and figure out how to fix it, I’ll let you know.