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.
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.
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:
- Install the Java SDK (JDK)
- Install the Android SDK and NDK
- Install Xamarin for Visual Studio
- Install Xamarin Studio for Windows (Optional)
- Configure Xamarin.Android
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:
JDK 8 is backwards compatible with all previous Android API levels.
Xamarin Android 7.0 and later requires JDK 8 in order to use Android Nougat (API 24) or later APIs.
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]
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:
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:
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:
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.
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:
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.
Run the SDK Manager – Navigate to your Android SDK directory in Explorer and double click on SDK Manager.exe to run it.
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:
To start installation, click the Install [x] packages button, accept the Android SDK licenses on the following screen and click Install, as displayed below:
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.
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:
Install Xamarin Studio for Windows (Optional)
Xamarin Studio is an open-source Integrated Development Environment (IDE) designed for building Mono-based applications.
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.
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
Once downloaded, click on the .exe file to install the product, and follow the Installation Wizard.
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
In the menu bar, navigate to Tools > Options > Xamarin > Android Settings as illustrated below:
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.
In the menu bar, navigate to Tools > Options > Projects > SDK Locations > Android as illustrated in the screenshot below:
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.
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.