blob: bc40ebd44b84ffd76abddbfc7336017c94b3dee2 [file] [log] [blame]
Trevor Johns682c24e2016-04-12 10:13:47 -07001page.title=Set Up the Preview
2meta.keywords="preview", "android"
3page.tags="preview", "developer preview"
4page.image=images/cards/card-n-sdk_2x.png
Joe Fernandez23fcc392015-05-19 12:27:07 -07005
Joe Fernandez306f1ce2015-05-01 12:51:21 -07006@jd:body
7
8
Joe Fernandez23fcc392015-05-19 12:27:07 -07009<div id="qv-wrapper">
10 <div id="qv">
Trevor Johns682c24e2016-04-12 10:13:47 -070011<ol>
12 <li><a href="#get-as13">Get Android Studio 2.1</a></li>
13 <li><a href="#get-sdk">Get the Android N SDK</a>
14 <ol>
15 <li><a href="#docs-dl">Reference documentation</a>
16 </ol>
17 </li>
18 <li><a href="#java8">Get the Java 8 JDK and JRE</a></li>
19 <li><a href="#create-update">Update or Create a Project</a></li>
20 <li><a href="#next">Next Steps</a></li>
21</ol>
Joe Fernandez23fcc392015-05-19 12:27:07 -070022 </div>
23</div>
Joe Fernandez306f1ce2015-05-01 12:51:21 -070024
Trevor Johns682c24e2016-04-12 10:13:47 -070025<p>To develop apps for the Android N Preview, you need to make some updates
26to your developer environment, as described on this page.</p>
27
28<p>To simply test your app's compatibility on the
29Android N system image, follow the guide to <a
30href="{@docRoot}preview/download.html">Test on an Android N Device</a>.</p>
31
32<img src="{@docRoot}preview/images/n-preview-setup.png" width="700" alt="" />
Joe Fernandezbd4ed322015-08-16 16:56:02 -070033
Joe Fernandez306f1ce2015-05-01 12:51:21 -070034
Trevor Johns682c24e2016-04-12 10:13:47 -070035<h2 id="get-as13">Get Android Studio 2.1 (preview)</h2>
Joe Fernandez23fcc392015-05-19 12:27:07 -070036
Trevor Johns682c24e2016-04-12 10:13:47 -070037<p>The Android N platform adds support for <a
38href="{@docRoot}preview/j8-jack.html">Java 8 language features</a>,
39which require a new compiler called Jack. The latest version of Jack
40is currently supported only in Android Studio 2.1. So if you want to
41use Java 8 language features, you need to use Android Studio 2.1 to
42build your app. Otherwise, you don't need to use the Jack compiler, but you
43still need to update to JDK 8 to compile against the Android N platform,
44as described below.
Joe Fernandezbd4ed322015-08-16 16:56:02 -070045</p>
Andrew Solovaya024a6d2015-05-27 11:07:35 -070046
Trevor Johns682c24e2016-04-12 10:13:47 -070047<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>
Joe Fernandez306f1ce2015-05-01 12:51:21 -070048
Trevor Johns682c24e2016-04-12 10:13:47 -070049<p>Android Studio 2.1 is currently available as a preview in the canary
50release channel. If you already
51have Android Studio and don't want to update to the canary channel, you can
52download Android Studio 2.1 as a separate installation and use it
53for development with Android N, leaving your primary Android Studio
54environment unaffected.</p>
Andrew Solovaya024a6d2015-05-27 11:07:35 -070055
Trevor Johns682c24e2016-04-12 10:13:47 -070056<p>To download Android Studio 2.1 as a separate installation, follow these
57steps (or if you want to receive Android Studio 2.1 as an update to your
58existing installation, skip to step 4):</p>
Andrew Solovaya024a6d2015-05-27 11:07:35 -070059
60<ol>
Trevor Johns682c24e2016-04-12 10:13:47 -070061 <li>Edit the name of your
62 existing Android Studio installation and append the version number. This way,
63 when you install the new version, it will not override the existing one.</li>
64 <li>Download the appropriate ZIP file for your operating system from the
65 <a href="http://tools.android.com/download/studio/canary/latest"
66 >canary channel download page</a>.
Andrew Solovaya024a6d2015-05-27 11:07:35 -070067 </li>
Trevor Johns682c24e2016-04-12 10:13:47 -070068 <li>Unzip the package and move the Android Studio 2.1 contents to the
69 appropriate location for applications on your system, then launch it.</li>
70 <li>Open the Settings dialog
71 (<strong>File &gt; Settings</strong> on Windows/Linux, or
72 <strong>Android Studio &gt; Preferences</strong> on Mac). In the left
73 panel, select <strong>Appearance &amp; Behavior &gt; System Settings &gt;
74 Updates</strong>.
Andrew Solovay525a0852015-05-28 10:56:57 -070075 </li>
Trevor Johns682c24e2016-04-12 10:13:47 -070076 <li>On the Updates panel, select the <strong>Automatically
77 check updates for</strong> check box and select
78 <strong>Canary Channel</strong> from the drop-down list.
Andrew Solovaya024a6d2015-05-27 11:07:35 -070079 </li>
80</ol>
Trevor Johns682c24e2016-04-12 10:13:47 -070081
82<p>Keep this settings window open for the next step.</p>
Joe Fernandez306f1ce2015-05-01 12:51:21 -070083
Joe Fernandez306f1ce2015-05-01 12:51:21 -070084
Trevor Johns682c24e2016-04-12 10:13:47 -070085<h2 id="get-sdk">Get the N Preview SDK</h2>
86
87<p>To start developing with Android N APIs, you need to install the
88Android N Preview SDK in Android Studio as follows:</p>
89
90<ol>
91 <li>While still viewing the Updates panel (step 4 from above),
92 select the <strong>Automatically
93 check updates for Android SDK</strong> check box and select
94 <strong>Preview Channel</strong> from the drop-down list.
95 </li>
96 <li>Click <strong>Check Now</strong>.</li>
97
98 <li>In the left panel, select <strong>Appearance &amp; Behavior &gt;
99 System Settings &gt; Android SDK</strong>.
100
101 <li>Click the <strong>SDK Platforms</strong> tab, then select the
102 <strong>Android N Preview</strong> check box.</li>
103
104 <li>Click the <strong>SDK Tools</strong> tab, then select the
105 <strong>Android SDK Build Tools</strong>, <strong>Android SDK
106 Platform-Tools</strong>, and <strong>Android SDK Tools</strong> check
107 boxes.
108 </li>
109
110 <li>Click <strong>OK</strong>, then accept the licensing
111 agreements for any packages that need to be installed.
112 </li>
113</ol>
114
115<h3 id="docs-dl">Get the N Preview reference documentation</h3>
Joe Fernandez23fcc392015-05-19 12:27:07 -0700116
117<p>
Trevor Johns682c24e2016-04-12 10:13:47 -0700118 Detailed information about the Android N APIs is available in the N Preview
119 reference documentation, which you can download from the following table.
120 This package contains an abridged, offline version of the Android developer
121 web site, and includes an updated API reference for the Android N APIs and an
122 API difference report.
Joe Fernandez23fcc392015-05-19 12:27:07 -0700123</p>
124
Trevor Johns682c24e2016-04-12 10:13:47 -0700125<table>
126 <tr>
127 <th scope="col">Documentation</th>
128 <th scope="col">Checksums</th>
129 </tr>
130 <tr>
131 <td style="white-space: nowrap">
132 <a href="{@docRoot}shareables/preview/n-preview-1-docs.zip"
133 >n-preview-1-docs.zip</a></td>
134 <td width="100%">
135 MD5: 4ab33ccbe698f46f125cc5b807cf9c2f<br>
136 SHA-1: 6a3880b3ccd19614daae5a4d0698ea6ae11c20a5
137 </td>
138 </tr>
139<table>
Joe Fernandez23fcc392015-05-19 12:27:07 -0700140
Trevor Johns682c24e2016-04-12 10:13:47 -0700141
142
143<h2 id="java8">Get the Java 8 JDK and JRE</h2>
144
145<p>To compile your app against the Android N platform, you need to use
146the Java 8 Developer Kit (JDK 8), and in order to use some tools with Android
147Studio 2.1, you need to install the Java 8 Runtime Environment (JRE 8). So, if
148you don't have the latest version of each already, download JDK 8 and JRE 8
149now.</p>
150
151<p>Then set the JDK version in Android Studio as follows:</p>
152
153<ol>
154 <li>Open an Android project in Android Studio, then open the
155 Project Structure dialog by selecting <strong>File &gt;
156 Project Structure</strong>. (Alternatively, you can set the default
157 for all projects by selecting <strong>File &gt; Other Settings &gt;
158 Default Project Structure</strong>.)
159 </li>
160 <li>In the left panel of the dialog, click <strong>SDK Location</strong>.
161 </li>
162 <li>In the <strong>JDK Location</strong> field, enter the location of the
163 Java 8 JDK (click the button on the right
164 to browse your files), then click <strong>OK</strong>.
165 </li>
166</ol>
167
168<img src="{@docRoot}preview/images/studio-jdk-location.jpg" width="700"
169 alt="" />
170
171
172<h2 id="create-update">Update or Create a Project</h2>
Joe Fernandez23fcc392015-05-19 12:27:07 -0700173
174<p>
Trevor Johns682c24e2016-04-12 10:13:47 -0700175 To use the Android N APIs, your project must be configured appropriately.
Joe Fernandez306f1ce2015-05-01 12:51:21 -0700176</p>
177
Trevor Johns682c24e2016-04-12 10:13:47 -0700178<p>If you plan to use Java 8 language features, you should also read
179<a href="{@docRoot}preview/j8-jack.html">Java 8 Language Features</a>
180for information about the supported Java 8 features and
181how to configure your project with the Jack compiler.</p>
Joe Fernandez306f1ce2015-05-01 12:51:21 -0700182
Joe Fernandez23fcc392015-05-19 12:27:07 -0700183
184<h3 id="update">Update an existing project</h3>
185
Trevor Johns682c24e2016-04-12 10:13:47 -0700186<p>Open the
187 <code>build.gradle</code> file for your module and update the values as
188 follows:
Joe Fernandez306f1ce2015-05-01 12:51:21 -0700189</p>
190
Trevor Johns682c24e2016-04-12 10:13:47 -0700191<pre>
192android {
193 compileSdkVersion <strong>'android-N'</strong>
194 buildToolsVersion <strong>'24.0.0-rc1'</strong>
195 ...
196
197 defaultConfig {
198 minSdkVersion <strong>'N'</strong>
199 targetSdkVersion <strong>'N'</strong>
200 ...
201 }
202 ...
203}</pre>
Joe Fernandez306f1ce2015-05-01 12:51:21 -0700204
205
Trevor Johns682c24e2016-04-12 10:13:47 -0700206<h3 id="create">Create a new project</h3>
Joe Fernandez306f1ce2015-05-01 12:51:21 -0700207
Joe Fernandez306f1ce2015-05-01 12:51:21 -0700208
Trevor Johns682c24e2016-04-12 10:13:47 -0700209<p>To create a new project for development with the Android N Preview SDK:</p>
Joe Fernandez306f1ce2015-05-01 12:51:21 -0700210
211<ol>
Trevor Johns682c24e2016-04-12 10:13:47 -0700212 <li>Click <strong>File > New Project</strong>. and follow the steps until
213 you reach the Target Android Devices page.
Joe Fernandez306f1ce2015-05-01 12:51:21 -0700214 </li>
Trevor Johns682c24e2016-04-12 10:13:47 -0700215 <li>On this page, select <strong>Phone and Tablet</strong> option.</li>
216 <li>Under <strong>Phone and Tablet</strong> option, in the <strong>Minimum
217 SDK</strong> option list, select
218 <strong>N: Android API 23, N Preview (Preview)</strong>.</li>
Joe Fernandez306f1ce2015-05-01 12:51:21 -0700219</ol>
220
Trevor Johns682c24e2016-04-12 10:13:47 -0700221
222<h2 id="next">Next Steps</h2>
223
224<ul>
225 <li>Follow the guide to <a
226href="{@docRoot}preview/download.html">Test on an Android N Device</a>.</li>
227 <li>Learn more about the Android N platform with
228<a href="{@docRoot}preview/behavior-changes.html">Behavior Changes</a>
229and <a href="{@docRoot}preview/api-overview.html">Android N APIs
230and Features</a>.</li>
231</ul>
232