page.title=Set Up the Preview
meta.keywords="preview", "android"
page.tags="preview", "developer preview"
page.image=images/cards/card-n-sdk_2x.png

@jd:body


<div id="qv-wrapper">
  <div id="qv">
<ol>
  <li><a href="#get-as13">Get Android Studio 2.1</a></li>
  <li><a href="#get-sdk">Get the Android N SDK</a>
    <ol>
      <li><a href="#docs-dl">Reference documentation</a>
    </ol>
  </li>
  <li><a href="#java8">Get the Java 8 JDK</a></li>
  <li><a href="#create-update">Update or Create a Project</a></li>
  <li><a href="#next">Next Steps</a></li>
</ol>
  </div>
</div>

<p>To develop apps for the Android N Preview, you need to make some updates
to your developer environment, as described on this page.</p>

<p>To simply test your app's compatibility on the
Android N system image, follow the guide to <a
href="{@docRoot}preview/download.html">Test on an Android N Device</a>.</p>

<img src="{@docRoot}preview/images/n-preview-setup.png" width="700" alt="" />


<h2 id="get-as13">Get Android Studio 2.1</h2>

<p>The Android N platform adds support for <a
href="{@docRoot}preview/j8-jack.html">Java 8 language features</a>,
which require a new compiler called Jack. The latest version of Jack
is currently supported only in Android Studio 2.1. So if you want to
use Java 8 language features, you need to use Android Studio 2.1 to
build your app. Otherwise, you don't need to use the Jack compiler, but you
still need to update to JDK 8 to compile against the Android N platform,
as described below.</p>

<p>If you already have Android Studio installed, make sure you have Android
Studio 2.1 or higher by clicking <strong>Help > Check for Update</strong>
(on Mac, <strong>Android Studio > Check for Updates</strong>).</p>

<p>If you don't have it, <a href="{@docRoot}studio/">download Android Studio
2.1 here</a>.</p>


<h2 id="get-sdk">Get the N Preview SDK</h2>

<p>To start developing with Android N APIs, you need to install the
Android N Preview SDK in Android Studio as follows:</p>

<ol>
  <li>Open the SDK Manager by clicking <strong>Tools > Android >
  SDK Manager</strong>.</li>

  <li>In the <strong>SDK Platforms</strong> tab, select the
  <strong>Android N Preview</strong> check box.</li>

  <li>Click the <strong>SDK Tools</strong> tab, then select the
    <strong>Android SDK Build Tools</strong>, <strong>Android SDK
    Platform-Tools</strong>, and <strong>Android SDK Tools</strong> check
    boxes.
  </li>

  <li>Click <strong>OK</strong>, then accept the licensing
    agreements for any packages that need to be installed.
  </li>
</ol>

<h3 id="docs-dl">Get the N Preview reference documentation</h3>

<p>Beginning with the Preview 4 release, the API reference for the
N platform (API level 24) is now available online at <a href=
  "{@docRoot}reference/">developer.android.com/reference/</a>.
</p>

<p>If you'd like an offline copy of the API reference, you can download it
from the following table. The download also includes an incremental diff report
for API changes between the Preview 3 and Preview 4 release, which is not
available online.</p>

<table>
  <tr>
    <th scope="col">Documentation</th>
    <th scope="col">Checksums</th>
  </tr>
  <tr>
    <td style="white-space: nowrap">
    <a href="{@docRoot}shareables/preview/n-preview-4-docs.zip"
      >n-preview-4-docs.zip</a></td>
    <td width="100%">
      MD5: f853e3ba0707083336dfa780b8fed9a7<br>
      SHA-1: 36fcbc497cc2e63b1bc1d629c304b0ba43a88946
    </td>
  </tr>
</table>



<h2 id="java8">Get the Java 8 JDK</h2>

<p>To compile your app against the Android N platform and use some tools with
Android Studio 2.1, you need to install the Java 8 Developer Kit (JDK 8). So, if
you don't already have the latest version, download JDK 8 now.</p>

<p>Then set the JDK version in Android Studio as follows:</p>

<ol>
  <li>Open an Android project in Android Studio, then open the
    Project Structure dialog by selecting <strong>File &gt;
        Project Structure</strong>. (Alternatively, you can set the default
        for all projects by selecting <strong>File &gt; Other Settings &gt;
        Default Project Structure</strong>.)
   </li>
   <li>In the left panel of the dialog, click <strong>SDK Location</strong>.
   </li>
   <li>In the <strong>JDK Location</strong> field, enter the location of the
    Java 8 JDK (click the button on the right
    to browse your files), then click <strong>OK</strong>.
   </li>
</ol>

<img src="{@docRoot}preview/images/studio-jdk-location.jpg" width="700"
  alt="" />


<h2 id="create-update">Update or Create a Project</h2>

<p>Now that the N platform API level is "24" instead
of "N", you can configure your projects normally with this API level (and even
publish your apps compiled with API 24 on Google Play). Just be sure that you've
updated your project to use <strong>Android SDK Build Tools 24.0.0</strong> and
<strong>Android SDK Platform-Tools 24.0.0</strong>.</p>

<p>If you plan to use Java 8 language features, you should also read
<a href="{@docRoot}preview/j8-jack.html">Java 8 Language Features</a>
for information about the supported Java 8 features and
how to configure your project with the Jack compiler.</p>


<h3 id="update">Update an existing project</h3>

<p>Open the
  <code>build.gradle</code> file for your module and update the values as
  follows:
</p>

<pre>
android {
  compileSdkVersion <strong>24</strong>
  buildToolsVersion <strong>'24.0.0'</strong>
  ...

  defaultConfig {
     targetSdkVersion <strong>24</strong>
     ...
  }
  ...
}</pre>

<p>Now that the API level 24 is final, you can compile against it and keep your
<code>minSdkVersion</code> to whatever version is appropriate for your app.</p>


<h3 id="create">Create a new project</h3>


<p>To create a new project for development with the Android N Preview SDK:</p>

<ol>
  <li>Click <strong>File > New Project</strong>. and follow the steps until
  you reach the <strong>Target Android Devices</strong> page.
  </li>
  <li>On this page, select the <strong>Phone and Tablet</strong> check box.</li>
  <li>Under <strong>Phone and Tablet</strong> option, in the <strong>Minimum
    SDK</strong> option list, select
    <strong>API 24: Android 6.X (N Preview)</strong>.</li>
</ol>


<h2 id="next">Next Steps</h2>

<ul>
  <li>Follow the guide to <a
href="{@docRoot}preview/download.html">Test on an Android N Device</a>.</li>
  <li>Learn more about the Android N platform with
<a href="{@docRoot}preview/behavior-changes.html">Behavior Changes</a>
and <a href="{@docRoot}preview/api-overview.html">Android N APIs
and Features</a>.</li>
</ul>