215 lines
7.1 KiB
Plaintext
Raw Normal View History

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
<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></li>
<li><a href="#java8">Get the Java 8 JDK and JRE</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 instead 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 (preview)</h2>
<p>The Android N platform adds support for Java 8 language features,
which are supported only with a new compiler called Jack. The latest Jack
compiler is currently supported only in Android Studio 2.1. So if you want to
use Java 8 language features, then you need to use Android Studio 2.1 to
build your app.
</p>
<iframe width="400" height="225" src="//www.youtube.com/embed/SBbWGxXCMqQ?autohide=1&amp;showinfo=0" frameborder="0" allowfullscreen="" style="float: right; margin: 0 0 20px 20px;"></iframe>
<p>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.</p>
<p>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):</p>
<ol>
<li>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.</li>
<li>Download the appropriate ZIP file for your operating system from the
<a href="http://tools.android.com/download/studio/canary/latest"
>canary channel download page</a>.
</li>
<li>Unzip the package and move the Android Studio 2.1 contents to the
appropriate location for applications on your system, then launch it.</li>
<li>Open the Settings dialog
(<strong>File &gt; Settings</strong> on Windows/Linux, or
<strong>Android Studio &gt; Preferences</strong> on Mac). In the left
panel, select <strong>Appearance &amp; Behavior &gt; System Settings &gt;
Updates</strong>.
</li>
<li>On the Updates panel, select the <strong>Automatically
check updates for</strong> check box and select
<strong>Canary Channel</strong> from the drop-down list.
</li>
</ol>
<p>Keep this settings window open for the next step.</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>While still viewing the Updates panel from the previous
procedure, select the <strong>Automatically
check updates for Android SDK</strong> check box and select
<strong>Preview Channel</strong> from the drop-down list.
</li>
<li>Click <strong>Check Now</strong>.</li>
<li>In the left panel, select <strong>Appearance &amp; Behavior &gt;
System Settings &gt; Android SDK</strong>.
<li>Click the <strong>SDK Platforms</strong> tab, then 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>
<p>In addition to these preview components, you should download the Android
N Preview API 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.</p>
<table id="docs-dl">
<tr>
<th scope="col">Documentation</th>
<th scope="col">Checksums</th>
</tr>
<tr>
<td style="white-space: nowrap">
<a href="https://storage.googleapis.com/androiddevelopers/preview/n-preview-1-docs.zip"
>n-preview-1-docs.zip</a></td>
<td width="100%">
MD5: 4ab33ccbe698f46f125cc5b807cf9c2f<br>
SHA-1: 6a3880b3ccd19614daae5a4d0698ea6ae11c20a5
</td>
</tr>
<table>
<h2 id="java8">Get the Java 8 JDK and JRE</h2>
<p>You also need to update your JDK for Java 8 and install the
Java 8 Runtime Environment (JRE) 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 JRE 8 now.</p>
<p>With Java 8 installed, 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>.
</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, then click <strong>OK</strong>.
</li>
</ol>
<h2 id="create-update">Update or Create a Project</h2>
<p>
To use the Android N APIs, your project must be configured appropriately.
</p>
<p>If you plan to use Java 8 language features, you should read
<a href="{@docRoot}preview/j8-jack.html">Using Java 8 Language Features</a>
for information about how to configure your project and the supported
Java 8 features.</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>'android-N'</strong>
buildToolsVersion <strong>24.0.0</strong>
...
defaultConfig {
...
minSdkVersion <strong>'N'</strong>
targetSdkVersion <strong>'N'</strong>
...
}
...
}</pre>
<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 Target Android Devices page.
</li>
<li>On this page, select <strong>Phone and Tablet</strong> option.</li>
<li>Under <strong>Phone and Tablet</strong> option, in the <strong>Minimum
SDK</strong> option list, select
<strong>N: Android API 23, N Preview (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>