Set Up the SDK

With Developer Preview 3, the official Android 6.0 SDK is now available from the Android SDK Manager. This document assumes that you are familiar with Android app development, such as using the Android SDK Manager and creating projects. If you are new to Android, see Building Your First App training lesson first.

Get Android Studio 1.3

It is highly recommended that you install the Android Studio 1.3 to work best with the Android 6.0 SDK. Please update your Android Studio installation to version 1.3 or higher, or follow the instructions for Installing Android Studio.

Get the Android 6.0 SDK

To add the Android 6.0 SDK components to your development environment:

  1. Launch Android Studio 1.3 or higher.
  2. Open the Settings window (on Windows, you can do this by choosing File > Settings). Choose the Appearance & Behavior > System Settings > Updates panel.

    On Mac OS X, you can find the Appearance & Behavior panel in Android Studio's Preferences window.

  3. On the Updates panel, choose the option for Automatically check updates for Android SDK: Preview Channel.
  4. Launch the Android SDK Manager. (With Android Studio 1.3, the SDK Manager is integrated into Android Studio instead of being a standalone application.)
  5. Under the Platforms section, select Android 6.0.
  6. In the Tools section, select the latest Android SDK Tools, Platform-tools, and Build-tools.
  7. Click Install packages and accept the licensing agreement for all of the packages.
  8. Verify that the Android 6.0 SDK is installed by opening the Settings window and choosing the Appearance & Behavior > System Settings > Android SDK panel.
  9. On the Android SDK panel, choose the SDK Platforms tab. Android 6.0 should be listed as Installed. Also, open the SDK Tools tab to verify that the latest tools are installed.

After completing these steps, the preview components are available in your development environment.

Create or Update a Project

In order to use the preview APIs, you must create or update a development project to use the preview components.

Create a new project

We recommend using Android Studio to create a project with the preview. Follow the steps described in Creating a Project until you arrive at the Form Factors screen in the project wizard. Then perform the following steps to create a project configured for the preview.

  • Check Phone and Tablet.
  • Select API 23: Android 6.0 (Marshmallow) in Minimum SDK.

Update an existing project

For existing projects, if you are using Android 6.0 APIs (API level 23) you must modify the project configuration. In your development environment, open the build.gradle file for your module and set these values as follows:

  • compileSdkVersion is set to '23'
  • targetSdkVersion is set to '23'

Set Up for Testing

Testing an app with the preview requires that you have a device or virtual device configured with the preview version of the platform. If you have a compatible device, you can install the preview platform for testing. Otherwise, you can configure a virtual device for testing.

Set up a physical device

If you have a Nexus 5, Nexus 6, Nexus 9, or Android TV, you can install a preview system image on these devices for testing your app. You can set up a virtual device with the preview version of the platform from within Android Studio using the Android Virtual Device Manager tool.

Important: Installing a preview image on a device removes all data from it, so you should backup any data before installing a preview image.

Set up a virtual device

You can set up virtual device with the preview version of the platform from within Android Studio using the Android Virtual Device Manager tool.

To create an AVD with the AVD Manager:

  1. Install the Preview SDK in your development environment, as described in Setting Up the Preview SDK.
  2. Follow the steps in Managing AVDs with AVD Manager. Use the following settings:
    • Device: Nexus 5, Nexus 6, Nexus 9, or Android TV
    • Target: Android M (Preview) - API Level M
    • ABI: x86

For more information about creating virtual devices for testing, see Managing Virtual Devices.