Protecting the code
As Android app packages are just ZIP files that contain the assemblies and metadata, the assemblies can easily be decompiled. As a result, we need a way to make it very difficult to understand the decompiled code, or even prevent it from happening altogether.
Getting ready
In this recipe, we will make use of the Babel for .NET obfuscator (https://babelfor.net/products/obfuscator). This is a commercial product, but they do have a demo version that can be used for free. The demo version does have a few limitations, and the obfuscated apps only run for a period of time, however this does not prevent us from using it.
There aren't many Mac/Linux obfuscators for .NET, and Babel for .NET is no different. We will also need a Windows machine to use the obfuscator, but we can use the MSBuild task to integrate with the build process for Xamarin.Android. As the MSBuild task does not have any specific IDE requirements, it will work with Xamarin Studio or Visual Studio.