page.title=Set Up to Develop for Android N
meta.keywords="preview", "android"
page.tags="preview", "developer preview"
page.image=images/cards/card-n-sdk_2x.png
@jd:body
To develop apps for Android using new APIs in Android N and new language
features of Java 8, you need to set up Android Studio 2.1 (preview) as described
on this page.
If you instead want to simply test your app's forward-compatibility on the
Android N system image, you can instead follow the guide to Test on an Android N Device.
Get Android Studio 2.1 (preview)
Developing for the Android N platform requires Java 8 and a new
compiler toolchain called JACK, which is currently supported only in
Android Studio 2.1.
Android Studio 2.1 is currently available as a preview in the canary
release channel. If you already
have Android Studio and don't want to update to the canary channel, you can
download Android Studio 2.1 as a separate installation and use it
with Android N, leaving your primary Android Studio environment
unaffected.
To download Android Studio 2.1 as a separate installation, follow these
steps (or if you want to receive Android Studio 2.1 as an update to your
existing installation, skip to step 4):
- Edit the name of your
existing Android Studio installation and append the version number. This way,
when you install the new version, it will not override the existing one.
- Download the appropriate ZIP file for your operating system from the
canary channel download page.
- Unzip the package and move the Android Studio 2.1 contents to the
appropriate location for applications on your system, then launch it.
- Open the Settings dialog
(File > Settings on Windows/Linux, or
Android Studio > Preferences on Mac). In the left
panel, select Appearance & Behavior > System Settings >
Updates.
- On the Updates panel, select the Automatically
check updates for check box and select
Canary Channel from the drop-down list.
Keep this settings window open for the next step.
Get the N Preview SDK
Now add the N Preview SDK to your Android Studio 2.1 development
environment as follows:
- While still viewing the Updates panel from the previous
procedure, select the Automatically
check updates for Android SDK check box and select
Preview Channel from the drop-down list.
- Click Check Now.
- In the left panel, select Appearance & Behavior >
System Settings > Android SDK.
- Click the SDK Platforms tab, then select the
Android N Preview check box.
- Click the SDK Tools tab, then select the
Android SDK Build Tools, Android SDK
Platform-Tools, and Android SDK Tools check
boxes.
- Click OK, then accept the licensing
agreements for any packages that need to be installed.
In addition to these preview components, you should download the
N Preview developer docs from the following table. This is an offline version
of the developer.android.com web site, except it includes the updated
API reference for the Android N APIs and an API difference report.
Documentation |
Checksums |
n-preview-1-docs.zip |
MD5: 129c447102a9f1fb3712234e5268a708
SHA-1: 2200b3b530ed15c8d48f768d6b00d2082d01c9c5
|
Get the Java 8 JDK and JRE
The Java 8 Development Kit (JDK) is required to develop apps with Android
N, and the Java 8 Runtime Environment (JRE) is required to run some
tools included in Android Studio 2.1. So, if you don't have the latest
version of each already, download JDK 8 and download JRE 8 now.
With Java 8 installed, set the JDK version in Android Studio as follows:
- Open an Android project in Android Studio, then open the
Project Structure dialog by selecting File >
Project Structure.
- In the left panel of the dialog, click SDK Location.
- In the JDK Location field, enter the location of the
Java 8 JDK, then click OK.
Update or Create a Project
To use the Android N APIs, your project must be configured appropriately.
Update an existing project
Open the
build.gradle
file for your module and update the values as
follows:
android {
compileSdkVersion 'android-N'
buildToolsVersion 24.0.0
...
defaultConfig {
...
minSdkVersion 'N'
targetSdkVersion 'N'
...
}
...
}
Create a new project
To create a new project for development with the N Preview SDK:
- Click File > New Project. and follow the steps until
you reach the Target Android Devices page.
- On this page, select Phone and Tablet option.
- Under Phone and Tablet option, in the Minimum
SDK option list, select
N: Android API 23, N Preview (Preview).
Next Steps
Now that you've set up Android Studio 2.1 (preview), follow the guide
to Test on an Android N Device.
And learn more about the Android N platform with
Behavior Changes
and Android N APIs
and Features.