Xamarin.Android Manual Installation

Installing Xamarin.Android on your Windows Machine

PDF for offline use
Related Articles:
Related Recipes:
Related Links:

Let us know how you feel about this

Translation Quality


0/250

last updated: 2017-02

Most of the time, the installation of Xamarin.Android and its required components is done through the Universal Installer, however in certain instances these components will need to be installed manually. This article walks through the installation steps and configuration details required to install the Xamarin.Android platform and its prerequisite components on Windows.

Overview

Developing Android applications on Windows can be done in either Xamarin Studio or Visual Studio with Xamarin.Android installed. Both Xamarin Studio and Xamarin.Android, can be installed through the Unified Installer, which is accessible through the Downloads page. The Unified (or Universal) Installer will install all products required for development on Windows, including the Xamarin.iOS and Xamarin.Android plugins for Visual Studio.

However in some instances, it may not be possible to use the Unified Installer - for example with a network restriction. In this case, it is possible to download each Xamarin product individually by accessing your store account, and manually installing each.

In this guide, we will walk through manually installing the Xamarin.Android platform and its external components. The following steps are required to manually install Xamarin.Android:

  1. Install the Java SDK (JDK)
  2. Install the Android SDK and NDK
  3. Install Xamarin for Visual Studio
  4. Install Xamarin Studio for Windows (Optional)
  5. Configure Xamarin.Android

Requirements

Xamarin.Android works with the following software versions:

  • Windows 7, Windows 8, Windows 8.1, or Windows 10
  • Visual Studio 2013 Update 2 (non Express editions) or Visual Studio 2015
  • Java JDK 8 (1.8)

If you are using a 64-bit version of Windows, the 64-bit version of JDK 8 (1.8) is recommended. This version is the most straightforward choice for the following reasons:

  1. JDK 8 is backwards compatible with all previous Android API levels.

  2. Xamarin Android 7.0 and later requires JDK 8 in order to use Android Nougat (API 24) or later APIs.

  3. The 64-bit JDK 8 supports the new Android designer features. For example, the 64-bit JDK 8 is required if you want to use custom controls in the Android Designer.

If you are using a 32-bit version of Windows, install the 32-bit version of the JDK.

If you still need to use legacy JDK 7 (1.7), JDK 8 can be installed alongside JDK 7. If you are using JDK 7, the 32-bit version must be installed. Also, you can continue to use earlier versions of the JDK if you are specifically targeting earlier Android API levels. The following lists the JDK versions that you can use with Xamarin.Android along with the Android levels that each JDK version supports:

One unfortunate complication with JDK 8 is that is not compatible with the version of Proguard that is currently included in the Android SDK. This incompatibility can cause the following error when you attempt to use the Proguard or Multidex features in Xamarin.Android:

Unsupported class version number [52.0]

For more information about this limitation, see 44187. For more information about Xamarin.Android requirements for Windows, see Windows Requirements.

Installing the Java SDK (JDK)

The JDK can be downloaded from any browser by visiting Oracle’s website and browsing to the section with the heading Java SE Development Kit. Before downloading the executable, you must first Accept License Agreement in the header. You can then download the Windows x64 version by clicking the package name jdk-8u121-windows-x64.exe (or later). This is shown in the screenshot below:

How to download the Java JDK from the Oracle website

It is recommend that the Java JDK be installed in its default location; this is where the IDE will check to see if it is installed. By default, the 64-bit version of the JDK is installed in the directory C:\Program Files\Java, and the 32-bit version of the JDK is installed under C:\Program Files (x86)\Java.

Install the Android SDK and NDK

The Android SDK contains all the tools and frameworks needed for developing an Android application. There are a number of steps needed to install it correctly, which are described below:

  1. Download the Android SDK – The SDK can be downloaded from the Android Studio website and will have a file name like tools_r[x].[x].[x]-windows.zip. It is not necessary to download the entire Android Studio bundle as we only need the SDK. Select the Windows zip file under Get just the command line tools as illustrated below:

    How to download the Android SDK from the Android developer website

  2. Extract the Android SDK – After downloading the SDK you will need to extract it. We recommend extracting the zip to C:\Program Files (x86)\Android\android-sdk however you can use another preferred location on your disk.

  3. Download the Android NDK – The Android Native Development kit is used to embed .NET assemblies into native libraries. While the NDK is generally not used for developing an Android application, we do recommend installing it. The NDK can be downloaded from the Android developer website. Select the Windows 32-bit zip file, which should be named something similar to android-ndk-r[X]-windows-x86.zip, as illustrated below:

    How to download the Android NDK from the Android developer website

    Once downloaded, extract the NDK to the same location as the SDK (C:\Program Files (x86)\Android). This should create a directory named android-ndk, potentially with a version number in the name.

  4. Run the SDK Manager – Navigate to your Android SDK directory in Explorer and double click on SDK Manager.exe to run it.

    In Windows Explorer, double click the SDK Manager executable to run it

  5. Install the required SDK Tools and APIs – Once launched, we can use the Android SDK manager to select the relevant components for installation. The latest version of the following components must always be selected:

    • Android SDK Tools
    • Android SDK Platform-tools
    • Android SDK Build-tools.

    These selections are indicated in the screenshot below:

    In the SDK Manager window, select Android SDK tools, platform tools, and build tools

    To start installation, click the Install [x] packages button, accept the Android SDK licenses on the following screen and click Install, as displayed below:

    How to accept the Android SDK licenses in the license agreement window and begin installation

  6. Install more Android Platforms – Deciding which platforms to install is entirely up to you, although it is recommended that at least the most popular platforms in the Android Dashboard be installed.

    You can select additional Android platforms in the SDK manager window

    The SDK manager can be accessed at any time through Visual Studio to add new or additional API versions by navigating to Tools > Android > Android SDK Manager…

Install Xamarin for Visual Studio

If you plan to develop with Visual Studio, you must already have a non-Express edition of Visual Studio 2013 Update 2 or any edition of Visual Studio 2015 installed on your machine. Xamarin can then be installed to allow development with Xamarin.Android in Visual Studio.

Installing either Xamarin.Android or Xamarin.iOS from the download page will install all necessary components for using Xamarin in Visual Studio. Therefore if you have already installed Xamarin.iOS, you can go ahead and skip this section.

To install Xamarin.Android, visit the Store page and navigate to Downloads. Then, in the Windows dropdown under Xamarin.Android, download the latest version:

How to download Xamarin for Visual Studio from the Xamarin account page

Install Xamarin Studio for Windows (Optional)

Xamarin Studio is an open-source Integrated Development Environment (IDE) designed for building Mono-based applications.

Install Gtk#

Gtk# is only needed if you plan to use Xamarin Studio in Windows. If you develop solely in Visual Studio you do not need to install it. Gtk# is a .NET binding for GTK+ and various GNOME libraries which together with C# and the System libraries provide developers with great productivity for building graphical applications especially when compared to Gtk+.

It can be downloaded from the Download section on the Mono website.

How to download Gtk for .NET from the Mono site

Install Xamarin Studio

To download Xamarin Studio, log in to your Xamarin account on the Store page and navigate to the Downloads page. Download the latest version from the Windows dropdown under Xamarin Studio

How to download Xamarin Studio from the Xamarin account website

Once downloaded, click on the .exe file to install the product, and follow the Installation Wizard.

Configure Xamarin.Android

Finally, after we’ve installed the different parts, we can configure them to complete our installation:

  • Configure the SDKs – Once we’ve installed the SDK prerequisites listed above, we will need to configure the paths to the SDK directories in Visual Studio and Xamarin Studio.

  • Configure the Emulator – In order to run and debug our Xamarin.Android applications, we need to use the Android Virtual Device (AVD) Manager to create and configure devices. Instructions for this can be found in the Configuring the Emulator guide.

Configure the SDKs

Visual Studio

In the menu bar, navigate to Tools > Options > Xamarin > Android Settings as illustrated below:

In the Visual Studio Options window, expand the Xamarin item in left side menu and select Android Settings

  • JDK: There is no option in Visual Studio to select the path for the JDK because the location is looked up in the Registry and set in the background.

  • Android SDK and NDK: In the Android SDK Location section, click Change and navigate to the SDK directory. Make sure that the correct path to the Android NDK is also specified.

Xamarin Studio

In the menu bar, navigate to Tools > Options > Projects > SDK Locations > Android as illustrated in the screenshot below:

In the Xamarin Studio Options window, expand the Projects and SDK Locations items in left side menu and select Android

  • JDK: Xamarin Studio will target the default location for the Java JDK. If the JDK was previously installed or was installed to a location other than the default, you can configure that path by clicking Browse and then navigating to the correct location.

  • Android SDK: In the Android SDK section, specify the installation path to the Android SDK by clicking Browse and then navigating to the Android SDK directory. Make sure that the correct path to the Android NDK is also specified.

Summary

Congratulations! Now that you have installed Xamarin.Android on Windows, you should get your device set up for development or configure the Android emulator.

In this article, we examined the components and steps needed to complete the Xamarin.Android installation. We looked at how to install and configure the required runtimes and SDKs, Xamarin Studio and Visual Studio, and how to configure Xamarin.Android for development.

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.