page.title=Set Up the SDK meta.keywords="preview", "android" page.tags="preview", "developer preview" page.image=images/cards/card-n-sdk_2x.png @jd:body
You must have a development enviroment to make use of the Android N Developer Preview. This document describes how to setup and configure a development environment so you can use and test the Preview SDK.
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.
The Developer Preview is best used with Android Studio 2.1, which is also in preview status. If you have an existing version of Android Studio you are using for development, you should install a separate instance of Android Studio for use with the Preview. This section describes how to install an instance of Android Studio and update to version 2.1.
Caution: The canary preview of Android Studio 2.1 is still in active development. If you are using your primary development machine to test the developer preview, you should create a second installation of Android Studio to use for testing the Developer Preview.
To install Android Studio and update to version 2.1:
You must use the Java 8 Development Kit with the N Developer Preview. If you do not have this version of the JDK installed, download and install it before working with the Preview SDK.
To set the JDK version in Android Studio:
To add the Preview SDK to your Android Studio 2.1 development environment:
After completing these steps, the preview components are available in your development environment.
In order to use the preview APIs, you must create or update a development project to use the preview components.
Use the Android Studio new project wizard to create a project. For detailed information on how to create a project with this too, see Creating a Project.
To create a new project using the Preview SDK:
For existing projects, you must modify the project configuration to use the
Preview APIs. In your development environment, open the
build.gradle
file for your module and set these values as
follows:
android { compileSdkVersion 'android-N' ... defaultConfig { ... minSdkVersion 'N' targetSdkVersion 'N' ... } ... }
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.
If you have a Nexus 5X, Nexus 6P, Nexus 9, or Nexus Player, 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.
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:
For more information about creating virtual devices for testing, see Managing Virtual Devices.