Baby Steps with Xamarin–Part 3

After my previous “not so hot” experience with the Android emulators, James was kind enough to ping me with his post over here around getting the Intel emulators and getting them to work on Windows 8.1

It was a bit disappointing to see that I’d have to enable/disable hyper-V when switching between Windows Phone/Android development but I can live with it. I disabled hyper-V and then installed the patch that James points to and then went ahead and installed the API 15 version of the “Intel x86 Atom System Image” via the “Android SDK Manager”.

I wasn’t sure at this point whether to just bite the bullet and move up to API 19 as I’m not looking to deploy anything to a real device but the Xamarin install had seemed to stop at 15 so I stopped there too.


That all worked fine and I tried to create a Nexus 7 device running on Atom;


but while I found that this seemed to start up a whole lot faster than the ARM based emulator images (not surprisingly) – it still had a problem;


and this was followed by a bunch of other “Unfortunately” error messages that told me that “Launcher” had also stopped.

I’d seen this in using some of the ARM based emulators as well so I wasn’t quite sure what was going on but I found a Stack Overflow article that seemed to suggest this might be to do with the setting for Heap Size (heap size for what? who knows Smile) so I played with a few settings for this and ended up with the same result event setting heap size to 64, 128, 256.

Giving Up on the Android Emulator

At this point I gave up on the Android emulator and moved to an actual device. I know the emulator can work. I’ve used it before. It’s not working for me on this PC though and I’ve wasted too much time on trying to get it working so I figured I’d just borrow a device and attempt to get things going that way.

I walked through;,_testing,_and_metrics/debugging_with_xamarin_android/

and finally I managed to run my “Hello World” blank application on that device and set a breakpoint and watch Visual Studio step through it;


and that was a blessed relief as I’d say it’d taken me a while longer than I’d hoped for just to get “Hello World” on the screen although none of that is anything to do with Xamarin and all of it is to do with Android emulators.

Getting Back to my Project

With “Hello World” up and running, I wanted to switch back to my project which I started back in the first post and see if I could add a blank Android project into that solution. That worked out fine;


and then I wanted to see if I could change the definitions of my CrossPlatform portable class library so that it targeted Android as an additional platform. The tooling’s smart here because I went to check its properties and it already said;


without me having to do anything. The next thing I wanted to know was whether I was “ok” to reference my portable code from my new Android project;


and that seemed to work out fine.

From there, I figured it was time to do a bit of reading as I’ve fudged my way around Android apps before without really knowing what I was doing and so I went off to read some of the Google docs.

I must say, I found them pretty good and I liked the way that they are structured – they read well to me and I like the “Continue Reading About” and “You Might Also Be Interested In” sections.

I started with;

  • Application Fundamentals
    • I found it fascinating that each app on an Android box is given its own dedicated Unix user. As an old Unix developer I can kind of see how this came to be but it struck me as a bit of a “wow” moment when I read it.
    • I learned a little about activities, services, content providers, broadcast receivers and intents.
    • Got a basic picture of the manifest.
  • Activities
    • By this point I was finding it “interesting” to compare/contrast what Android has as an Activity versus the structure of a typical Windows/Phone app into a set of Pages where those Pages live within the app and aren’t something that the operating system is really told about and so some app A can’t really invoke Page P of some other app B (although similar things might be achieved by app B handling some protocol).
    • I found the Activity lifecycle diagram quite entertaining. Having explained the various lifecycles of the Windows/Phone platforms to developers it’s interesting to see another take on what is, essentially, the same thing and I tried to follow through the table with all the little caveats around what happens when and the idea of a Bundle being passed to an Activity as a way of recreating it when the system’s killed it.
  • User Interface
    • I flicked through this – it made sense to me although I took a reasonably long look at the sections about displaying lists – I was bit worried by the ListView page in that it seemed a relatively drawn out process to get a list of data displayed on the screen.

from thereon in, I’m willing to see if I can replicate the small pieces of functionality from my original “app” in Android – what I’m expecting is to have to manually wire things together rather than be able to use data-binding as I have in my Windows/Phone projects and to have to come up with some way of seeing whether the INavigationService abstraction that I built previously is flexible enough to be able to hide some class that switches between Android Activity instances underneath it.

I’ll put that in the next post…I may be some time… Smile