2016-03-07 22:13:29 -08:00
|
|
|
page.title=Set Up to Develop for Android N
|
2016-03-03 14:53:16 -08:00
|
|
|
meta.keywords="preview", "android"
|
|
|
|
page.tags="preview", "developer preview"
|
|
|
|
page.image=images/cards/card-n-sdk_2x.png
|
2016-02-06 18:24:32 -08:00
|
|
|
|
|
|
|
@jd:body
|
|
|
|
|
|
|
|
|
|
|
|
<div id="qv-wrapper">
|
|
|
|
<div id="qv">
|
2016-03-07 16:38:37 -08:00
|
|
|
<ol>
|
|
|
|
<li><a href="#get-as13">Get Android Studio 2.1</a></li>
|
2016-03-07 22:13:29 -08:00
|
|
|
<li><a href="#get-sdk">Get the Android N SDK</a></li>
|
2016-03-07 16:38:37 -08:00
|
|
|
<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>
|
2016-02-06 18:24:32 -08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2016-03-02 21:30:31 -08:00
|
|
|
<p>
|
2016-03-07 22:13:29 -08:00
|
|
|
To develop apps for Android using new APIs in Android N and new language
|
2016-03-07 16:38:37 -08:00
|
|
|
features of Java 8, you need to set up Android Studio 2.1 (preview) as described
|
|
|
|
on this page.</p>
|
2016-03-02 21:30:31 -08:00
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
<p>If you instead want to simply test your app's forward-compatibility on the
|
2016-03-07 22:13:29 -08:00
|
|
|
Android N system image, you can instead follow the guide to <a
|
2016-03-08 17:25:50 -08:00
|
|
|
href="{@docRoot}preview/download.html">Test on an Android N Device</a>.</p>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
|
|
|
|
2016-03-08 18:42:51 -08:00
|
|
|
<img src="{@docRoot}preview/images/n-preview-setup.png" width="700" alt="" />
|
|
|
|
|
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
<h2 id="get-as13">Get Android Studio 2.1 (preview)</h2>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
2016-03-07 22:13:29 -08:00
|
|
|
<p>Developing for the Android N platform requires Java 8 and a new
|
2016-03-07 16:38:37 -08:00
|
|
|
compiler toolchain called JACK, which is currently supported only in
|
|
|
|
Android Studio 2.1.
|
2016-02-06 18:24:32 -08:00
|
|
|
</p>
|
|
|
|
|
2016-03-08 13:27:37 -08:00
|
|
|
<iframe width="400" height="225" src="//www.youtube.com/embed/SBbWGxXCMqQ?autohide=1&showinfo=0" frameborder="0" allowfullscreen="" style="float: right; margin: 0 0 20px 20px;"></iframe>
|
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
<p>Android Studio 2.1 is currently available as a preview in the canary
|
2016-03-08 13:27:37 -08:00
|
|
|
release channel. If you already
|
2016-03-07 16:38:37 -08:00
|
|
|
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
|
2016-03-07 22:13:29 -08:00
|
|
|
with Android N, leaving your primary Android Studio environment
|
2016-03-07 16:38:37 -08:00
|
|
|
unaffected.</p>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
<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>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
|
|
|
<ol>
|
2016-03-07 16:38:37 -08:00
|
|
|
<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>.
|
2016-02-06 18:24:32 -08:00
|
|
|
</li>
|
2016-03-07 16:38:37 -08:00
|
|
|
<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 > Settings</strong> on Windows/Linux, or
|
|
|
|
<strong>Android Studio > Preferences</strong> on Mac). In the left
|
|
|
|
panel, select <strong>Appearance & Behavior > System Settings >
|
2016-03-02 21:30:31 -08:00
|
|
|
Updates</strong>.
|
2016-02-06 18:24:32 -08:00
|
|
|
</li>
|
2016-03-07 16:38:37 -08:00
|
|
|
<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.
|
2016-02-06 18:24:32 -08:00
|
|
|
</li>
|
2016-03-02 21:30:31 -08:00
|
|
|
</ol>
|
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
<p>Keep this settings window open for the next step.</p>
|
2016-03-02 21:30:31 -08:00
|
|
|
|
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
<h2 id="get-sdk">Get the N Preview SDK</h2>
|
2016-03-02 21:30:31 -08:00
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
<p>Now add the N Preview SDK to your Android Studio 2.1 development
|
|
|
|
environment as follows:</p>
|
2016-03-02 21:30:31 -08:00
|
|
|
|
|
|
|
<ol>
|
2016-03-07 16:38:37 -08:00
|
|
|
<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.
|
2016-03-02 21:30:31 -08:00
|
|
|
</li>
|
2016-03-07 16:38:37 -08:00
|
|
|
<li>Click <strong>Check Now</strong>.</li>
|
2016-03-02 21:30:31 -08:00
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
<li>In the left panel, select <strong>Appearance & Behavior >
|
|
|
|
System Settings > Android SDK</strong>.
|
2016-02-06 18:24:32 -08:00
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
<li>Click the <strong>SDK Platforms</strong> tab, then select the
|
|
|
|
<strong>Android N Preview</strong> check box.</li>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
<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.
|
2016-02-06 18:24:32 -08:00
|
|
|
</li>
|
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
<li>Click <strong>OK</strong>, then accept the licensing
|
|
|
|
agreements for any packages that need to be installed.
|
2016-02-06 18:24:32 -08:00
|
|
|
</li>
|
|
|
|
</ol>
|
2016-03-02 21:30:31 -08:00
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
<p>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
|
2016-03-07 22:13:29 -08:00
|
|
|
API reference for the Android N APIs and an API difference report.</p>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
<table id="docs-dl">
|
|
|
|
<tr>
|
|
|
|
<th scope="col">Documentation</th>
|
|
|
|
<th scope="col">Checksums</th>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td style="white-space: nowrap">
|
2016-03-08 18:35:18 -08:00
|
|
|
<a href="{@docRoot}shareables/preview/n-preview-1-docs.zip"
|
2016-03-07 16:38:37 -08:00
|
|
|
>n-preview-1-docs.zip</a></td>
|
|
|
|
<td width="100%">
|
2016-03-08 16:44:08 -08:00
|
|
|
MD5: 129c447102a9f1fb3712234e5268a708<br>
|
|
|
|
SHA-1: 2200b3b530ed15c8d48f768d6b00d2082d01c9c5
|
2016-03-07 16:38:37 -08:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<table>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
<h2 id="java8">Get the Java 8 JDK and JRE</h2>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
|
|
|
<p>
|
2016-03-07 22:13:29 -08:00
|
|
|
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
|
2016-03-08 16:44:08 -08:00
|
|
|
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.</p>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
<p>With Java 8 installed, set the JDK version in Android Studio as follows:</p>
|
2016-03-02 21:30:31 -08:00
|
|
|
|
|
|
|
<ol>
|
2016-03-07 16:38:37 -08:00
|
|
|
<li>Open an Android project in Android Studio, then open the
|
|
|
|
Project Structure dialog by selecting <strong>File >
|
|
|
|
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>
|
2016-03-02 21:30:31 -08:00
|
|
|
</ol>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
<h2 id="create-update">Update or Create a Project</h2>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
|
|
|
<p>
|
2016-03-07 22:13:29 -08:00
|
|
|
To use the Android N APIs, your project must be configured appropriately.
|
2016-03-07 16:38:37 -08:00
|
|
|
</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
|
2016-03-02 21:30:31 -08:00
|
|
|
follows:
|
2016-02-06 18:24:32 -08:00
|
|
|
</p>
|
|
|
|
|
2016-03-02 21:30:31 -08:00
|
|
|
<pre>
|
|
|
|
android {
|
|
|
|
compileSdkVersion <strong>'android-N'</strong>
|
2016-03-07 16:38:37 -08:00
|
|
|
buildToolsVersion <strong>24.0.0</strong>
|
2016-03-02 21:30:31 -08:00
|
|
|
...
|
|
|
|
|
|
|
|
defaultConfig {
|
|
|
|
...
|
|
|
|
minSdkVersion <strong>'N'</strong>
|
|
|
|
targetSdkVersion <strong>'N'</strong>
|
|
|
|
...
|
|
|
|
}
|
|
|
|
...
|
|
|
|
}</pre>
|
|
|
|
|
2016-02-06 18:24:32 -08:00
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
<h3 id="create">Create a new project</h3>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
<p>To create a new project for development with the N Preview SDK:</p>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
|
|
|
<ol>
|
2016-03-07 16:38:37 -08:00
|
|
|
<li>Click <strong>File > New Project</strong>. and follow the steps until
|
|
|
|
you reach the Target Android Devices page.
|
2016-02-06 18:24:32 -08:00
|
|
|
</li>
|
2016-03-07 16:38:37 -08:00
|
|
|
<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>
|
2016-02-06 18:24:32 -08:00
|
|
|
</ol>
|
|
|
|
|
2016-03-07 16:38:37 -08:00
|
|
|
|
|
|
|
<h2 id="next">Next Steps</h2>
|
|
|
|
|
|
|
|
<p>Now that you've set up Android Studio 2.1 (preview), follow the guide
|
|
|
|
to <a
|
2016-03-08 17:25:50 -08:00
|
|
|
href="{@docRoot}preview/download.html">Test on an Android N Device</a>.
|
2016-03-08 16:44:08 -08:00
|
|
|
And learn more about the Android N platform with
|
2016-03-07 16:38:37 -08:00
|
|
|
<a href="{@docRoot}preview/behavior-changes.html">Behavior Changes</a>
|
|
|
|
and <a href="{@docRoot}preview/api-overview.html">Android N APIs
|
|
|
|
and Features</a>.</p>
|
|
|
|
|