Running MonoGame on Android Wear

Getting MonoGame projects to run on Android Wear requires a different setup than normal solutions, from emulator to asset settings.

First problem I ran into looked like below and was easily enough solved by activating the “Use Host GPU” option when creating a new emulator image.

 OpenTK.Platform.Android.EglException: Failed to find a valid GraphicsMode configuration

Since MonoGame is available on NuGet, I started by creating an Android Wear solution and adding the framework binaries. But adding the project images in the usual “drawable” folder was giving me the following error.

Could not load * asset as a non-content file

This was triggered by the lacking Content directory in my project structure, the place where all the assets should go and which ends up in the resources bundle at runtime.

Also important, I marked my assets with the “AndroidAsset” build action, instead on “Content” or “AndroidResource”.

Memory management in mobile apps

Throughout it’s lifetime, an application is allowed to make use of the internal memory, as object instances obtain parts of it for temporary use and then return it. When an objects doesn’t use the memory anymore but refuses to let it go, a memory leak is created.

Common causes of memory leaks

Soon a leak can turn into a flood, as the memory occupation is small, but constant and the gradual loss of memory will make the application unresponsive.

There are a few common causes for which memory leaks happen. Continue reading

Unit testing caveats

There is much controversy regarding test driven development. People do not seem to settle on the time trade-off, the London vs. State school, TDD vs BDD and the list could go on. But before diving into all of these, my first reports from the tranches of unit testing are as follows.

Behavior depending on date and time conditions

Tests should be runnable at any hour. Even if we leave the office at 6PM and everything seems to work properly, having loose DateTime variables in the tests could mean that they will fail during the automatic build that is run every night.

For example, we might want to ensure that our newsletter goes out only on Mondays. In this case, using an ICommand would make sense, because we can verify that our condition has been met before executing the action. A Command accepts a CanExecute Action that could like this one:

Func<Email, bool> canSendEmail = (email) =>
{
    if (email.DateToBeSent.DayOfWeek == DayOfWeek.Monday)
        return true;
    return false;
};

Continue reading

See you at MonkeySpace 2014!

MonkeySpace is the official cross platform and open-source .NET conference, a great place to collaborate, share, and socialize about the latest things in mobile and *nix platforms development. The 2014 edition will be hosted in Dublin, Ireland, on the 9th-11th of June.

If you’d like to see what happened in previous editions, take a look at the sessions from MonkeySpace 2012 and MonkeySpace 2013.

This year I am lucky enough to share the stage with other awesome speakers and I will be sharing tips and tricks about cross-platform development. My session will be called “Maximizing code sharing across platforms” and will start at 17:30, on the second day (June 10th). A strong point of the Xamarin SDK is that it allows code to be shared across platforms and from architecture to libraries, we’ll explore together some ways to maximize the code reuse.

See you there!

Zen Monday: Case sensitivity

iOS Case Sensitivity

Get started with MonoGame in 5 easy steps

MonoGame is the little brother of Mono: a small and cool platform for making (mostly) 2D games. It’s an open source implementation of XNA and is compatible with iOS, Android, Mac, MacOS, Linux and Windows 8 (support for more platforms is coming). If however, more complex and 3D games is your thing, you can head out to Unity3D, also in the Mono family.

1. Get MonoGame from CodePlex

Download the latest MonoGame version from Codeplex. The is are multiple versions: a Windows one, a MonoDevelop one and, finally, the one we need, the Xamarin version. They each come as an .mpack, which needs to be installed in the corresponding IDE.
Continue reading