Monday, February 9, 2015

Android SDK Manager Setup for Xamarin.Android and Xamarin Forms Development

Setting up the Android the SDK can be a bit overwhelming if you’re new to Android development. Especially compared to other mobile platforms like Windows Phone and iOS, where you just install the latest versions and start developing.
My Goal with this article is to clarify the purpose of the installable packages in the SDK manager as well as give you some guidance as to what you should install when developing Xamarin Apps.
If you don't want to read through all of the details, jump to the bottom to view my configuration.
More info:



The Xamarin installer will download and install all of the tooling you need to develop Xamarin.Android applications. And this includes the SDK Manager. You shouldn’t need to install the Android SDKs manually, but if you do you can check out Android’s documentation here:


How to Launch the SDK Manager

As Xamarin developers, the easiest way to open to Android SDK Manager is through your favorite IDE. Both Visual Studio and Xamarin Studio have launch points in their menus.
In Visual Studio, click on “Tools -> Android -> Android SDK Manager …”
In Xamarin Studio, click “Tools -> Open Android SDK Manager …”


Android SDK Manager Packages

The Android SDK Manager allows you to select which packages you want to install. I’ll discuss each option, working from the top to the bottom, and give you recommendations for what to install.



Let’s start in the Tools section.


Android SDK Tools

The first option you’ll see is the Android SDK Tools. These are the development and debugging tools for the Android SDK and you’ll need these installed in order to compile Xamarin.Android Applications. Install this and keep it up to date.
Recommendation: must install
More info:


Android SDK Platform-tools

The Platform tools contain additional tools for connecting to devices and emulators to deploy builds and debug applications. You should always have the latest version of the platform tools to ensure compatibility with the latest version of the Android APIs; so keep this up to date as well.
Recommendation: must install


Android SDK Build-tools

The Build Tools are required for actually building/compiling your source code into an application that can be run on the Android platform. You should AWLAYS install the latest version which will be used by default during compilation. If your project depends on an older version, the SDK Manager allows you to install and maintain separate versions. In my experience this is rarely necessary and I only install the latest version.
Recommendation: install latest version only
More info:


Android APIs

After the Tools section you’ll see sections for each Android API. Typically when a new version of the Android operating system is released, Google also updates the APIs which allow you to develop with the latest features and fixes. You’ll see the Android version listed (i.e. 5.0.1) along with the API level (API 21). There are a lot of options here, let’s look at each one and then discuss which version(s) of the API to install.


Documentation for Android SDK

There is documentation for each API level and this is written for Java Android developers. It can be installed but it’s not often used by Xamarin developers, and it’s not required.
Recommendation: don’t install


SDK Platform

The SDK Platform for a given API level allows you to compile against that version of Android. Newer platforms require newer versions of the SDK Platform-tools and SDK Tools (mentioned above) which is why we need to keep those up to date.
Recommendation: must install


Samples for SDK

These are Java samples included with each API level. These are not required and Xamarin developers don’t typically use these, but they can be examined and ported to C#.
Recommendation: don’t install unless you have a specific use or lots of storage space


System Images

These are system images that can be used with Android virtual devices. On later API levels, both ARM and x86 images are included. The x86 images will run significantly faster and should be preferred over the ARM equivalents. The images prefixed with “Google APIs” include the Google Play Services runtime and are useful for testing Google Play Services features such as mapping. These versions are recommended over the “plain” versions. Note – the System Images take up a significant amount of disk space so you should only install them if you’re using them.
Recommendation: don’t install if you’re using the Xamarin Android Player or Genymotion. Otherwise, install x86 Google API images as needed.


Google APIs

Most API levels include a package called Google APIs. This includes additional documentation, samples and libraries for the Google APIs for that version of Android for Java developers. These libraries are not needed if you’re using Xamarin even if coding against the Google APIs.
Recommendation: don’t install


Sources for Android SDK

For some API levels Google has released the source code. Unless you’re specifically interested in viewing the source code for the Android SDK, I wouldn’t recommend installing it, and it’s not needed for application development.
Recommendation: don’t install


*API Levels

Now that we understand what the individual pieces do, you’re probably asking, “which API levels do I install?”. In an ideal world you would just install the latest version, since you can still target older versions of Android with the latest SDK. However, APIs do change between versions and with that, you may find example code or example projects that are designed for, and targeting older versions. The good news is, each SDK Platform only uses about 100 megabytes of space. So for simplicity, you can safely install every SDK Platform (which will consumes ~2GB of space).
Recommendation: install each SDK Platform from API level 14 to the latest. If space allows, install every SDK Platform.



Our final section is Extras. The packages in this section include extra functionality and tools you can optionally use during development. I won’t cover all the packages, just the ones I recommend you install.


Android Support Library

The Android Support Library is a package that provides backwards compatibility for new API features on older devices. Additionally, Google releases some features and controls that are ONLY available in the support libraries. It’s considered “best practice” to use the Support Libraries for some features during development.
Recommendation: highly recommended to install
More info:


Google Play Services

The Google Play Services provide APIs to develop using extra Android features created by Google, this includes technologies such as Google Maps and Google+. Note – devices must have the Google Play Services Runtime installed to use these additional APIs. Almost all new Android devices include the runtime - notable exclusions include the Kindle Fire devices. Generally, Android emulators don’t include the Google Play Services runtime by default but it can be installed separately.
Recommendation: highly recommended to install
More info:


Google USB Driver

The Google USB Driver enables USB debugging for most Android devices from Windows. Note - for some devices, you may need to install device specific drivers provided by the manufacturer. USB debugging is somewhat inconsistent on Windows 8.x, it can be unreliable to connect and some devices tend to work more reliably than others (ie Nexus). The driver isn’t used on OSX.
Recommendation: install if using Windows


Quick Reference

If you don’t want to read all of the above – take a look at the image below to view my (Windows) configuration: