Android 10 with Xamarin

How to get started developing apps for Android 10 using Xamarin.Android.

Android 10 is now available from Google. A number of new features and APIs are being made available in this release, and many of them are necessary to take advantage of new hardware capabilities in the latest Android devices.

Android 10 Logo

This article is structured to help you get started in developing Xamarin.Android apps for Android 10. It explains how to install the necessary updates, configure the SDK, and prepare an emulator or device for testing. It also provides an outline of the new features in Android 10 and provides example source code that illustrates how to use some of the key Android 10 features.

Xamarin.Android 10.0 provides support for Android 10. For more information about Xamarin.Android support for Android 10, see the Xamarin.Android 10.0 release notes.

Requirements

The following list is required to use Android 10 features in Xamarin-based apps:

  • Visual Studio - Visual Studio 2019 is recommended. On Windows update to Visual Studio 2019 version 16.3 or later. On macOS, update to Visual Studio 2019 for Mac version 8.3 or later.
  • Xamarin.Android - Xamarin.Android 10.0 or later must be installed with Visual Studio (Xamarin.Android is automatically installed as part of the Mobile Development With .NET workload on Windows and installed as part of the Visual Studio for Mac Installer)
  • Java Developer Kit - Xamarin.Android 10.0 development requires JDK 8. Microsoft's distribution of the OpenJDK is automatically installed as part of Visual Studio.
  • Android SDK - Android SDK API 29 must be installed via the Android SDK Manager.

Get started

To get started developing Android 10 apps with Xamarin.Android, you must download and install the latest tools and SDK packages before you can create your first Android 10 project:

  1. Visual Studio 2019 is recommended. Update to Visual Studio 2019 version 16.3 or later. If you are using Visual Studio for Mac 2019, update to Visual Studio 2019 for Mac version 8.3 or later.
  2. Install Android 10 (API 29) packages and tools via the SDK Manager.
    • Android 10 (API 29) SDK Platform
    • Android 10 (API 29) System Image
    • Android SDK Build-Tools 29.0.0+
    • Android SDK Platform-Tools 29.0.0+
    • Android Emulator 29.0.0+
  3. Create a new Xamarin.Android project that targets Android 10.0.
  4. Configure an emulator or device for testing Android 10 apps.

Each of these steps is explained below:

Update Visual Studio

Visual Studio 2019 is recommended for building Android 10 apps using Xamarin.

If you are using Visual Studio 2019, update to Visual Studio 2019 version 16.3 or later (for instructions, see Update Visual Studio 2019 to the most recent release). On macOS, update to Visual Studio 2019 for Mac 8.3 or later (for instructions, see Update Visual Studio 2019 for Mac to the most recent release).

Install the Android SDK

To create a project with Xamarin.Android 10.0, you must first use the Android SDK Manager to install the SDK platform for Android 10 (API level 29).

  1. Start the SDK Manager. In Visual Studio, click Tools > Android > Android SDK Manager. In Visual Studio for Mac, click Tools > SDK Manager.

  2. In the lower right-hand corner, click the gear icon and select Repository > Google (Unsupported):

    Android SDK Manager Repository Selection

  3. Install the Android 10 SDK Platform packages, which are listed as Android SDK Platform 29 in the Platforms tab (for more information about using the SDK Manager, see Android SDK setup):

    Android SDK Manager Platform Tab

Create a Xamarin.Android project

Create a new Xamarin.Android project. If you are new to Android development with Xamarin, see Hello, Android to learn about creating Xamarin.Android projects.

When you create an Android project, you must configure the version settings to target Android 10.0 or later. For example, to target your project for Android 10, you must configure the target Android API level of your project to Android 10.0 (API 29). This includes both your Target Framework Version and Target Android SDK Version to API 29 or later. For more information about configuring Android API levels, see Understanding Android API Levels.

Xamarin.Android Target Framework

Configure a device or emulator

If you are using a physical device such as a Pixel, you can download the Android 10 update by going to the System > System update > Check for update in your phone's settings. If you'd prefer to flash your device, please see the instructions on flashing a Factory Image or OTA Image to your device.

If you are using an emulator, create a virtual device for API level 29 and select an x86-based image. For information about using the Android Device Manager to create and manage virtual devices, see Managing Virtual Devices with the Android Device Manager. For information about using the Android Emulator for testing and debugging, see Debugging on the Android Emulator.

New features

Android 10 introduces a variety of new features. Some of these new features are intended to leverage new hardware capabilities offered by the latest Android devices, while others are designed to further enhance the Android user experience:

Enhance your app with Android 10 features and APIs

Next, when you're ready, dive into Android 10 and learn about the new features and APIs that you can use. Here are some of the top features to get started with.

These features are recommend for every app:

  • Dark Theme: Ensure a consistent experience for users who enable system-wide dark theme by adding a Dark Theme or enabling Force Dark.

Dark Theme

  • Support gestural navigation in your app by going edge-to-edge and making sure your custom gestures are complementary to the system navigation gestures.

Gesture Navigation

  • Optimize for foldables: Deliver seamless, edge-to-edge experiences on today’s innovative devices by optimizing for foldables.

Foldable

These features are recommended if relevant for your app:

  • More interactive notifications: If your notifications include messages, enable suggested replies and actions in notifications to engage users and let them take action instantly.
  • Better biometrics: If you use biometric auth, move to BiometricPrompt, the preferred way to support fingerprint auth on modern devices.
  • Enriched recording: To support captioning or gameplay recording, enable audio playback capture. It’s a great way to reach more users and make your app more accessible.
  • Better codecs: For media apps, try AV1 for video streaming and HDR10+ for high dynamic range video. For speech and music streaming, you can use Opus encoding, and for musicians, a native MIDI API is available.
  • Better networking APIs: If your app manages IoT devices over Wi-Fi, try the new network connection APIs for functions like configuring, downloading, or printing.

These are just a few of the many new features and APIs in Android 10. To see them all, visit the Android 10 site for developers.

Behavior changes

When the Target Android Version is set to API level 29, there are several platform changes that cann affect your app's behavior even if you are not implementing the new features described above. The following list is a brief summary of these changes:

Summary

This article introduced Android 10 and explained how to install and configure the latest tools and packages for Xamarin.Android development with Android 10. It provided an overview of the key features available in Android 10. It included links to API documentation and Android Developer topics to help you get started in creating apps for Android 10. It also highlighted the most important Android 10 behavior changes that could impact existing apps.