blob: 3e95f3e864c0d959df55d32e7d137c3b8dca4c82 [file] [log] [blame]
Dirk Doughertycf65e4842016-03-07 22:31:57 -08001page.title=Set Up the Preview
Dirk Dougherty43eb9512016-03-03 14:53:16 -08002meta.keywords="preview", "android"
3page.tags="preview", "developer preview"
4page.image=images/cards/card-n-sdk_2x.png
Dirk Dougherty5748bc42016-02-06 18:24:32 -08005
6@jd:body
7
8
9<div id="qv-wrapper">
10 <div id="qv">
smain@google.com0a03f312016-03-07 16:38:37 -080011<ol>
12 <li><a href="#get-as13">Get Android Studio 2.1</a></li>
Joe Fernandez98b0ec62016-03-08 22:32:51 -080013 <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>
Mary Yanchar1986a6e2016-03-30 13:56:12 -070018 <li><a href="#java8">Get the Java 8 JDK</a></li>
smain@google.com0a03f312016-03-07 16:38:37 -080019 <li><a href="#create-update">Update or Create a Project</a></li>
20 <li><a href="#next">Next Steps</a></li>
21</ol>
Dirk Dougherty5748bc42016-02-06 18:24:32 -080022 </div>
23</div>
24
smain@google.com67894042016-03-08 21:14:47 -080025<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>
smain@google.com0a03f312016-03-07 16:38:37 -080027
smain@google.coma329ffd2016-03-09 00:00:37 -080028<p>To simply test your app's compatibility on the
smain@google.com67894042016-03-08 21:14:47 -080029Android N system image, follow the guide to <a
smain@google.com3254f8c2016-03-08 17:25:50 -080030href="{@docRoot}preview/download.html">Test on an Android N Device</a>.</p>
smain@google.com0a03f312016-03-07 16:38:37 -080031
smain@google.com02573e02016-03-08 18:42:51 -080032<img src="{@docRoot}preview/images/n-preview-setup.png" width="700" alt="" />
33
34
smain@google.com8ac737d2016-04-22 15:27:28 -070035<h2 id="get-as13">Get Android Studio 2.1</h2>
smain@google.com0a03f312016-03-07 16:38:37 -080036
smain@google.coma329ffd2016-03-09 00:00:37 -080037<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,
smain@google.com8ac737d2016-04-22 15:27:28 -070044as described below.</p>
Dirk Dougherty5748bc42016-02-06 18:24:32 -080045
smain@google.com8ac737d2016-04-22 15:27:28 -070046<p>If you already have Android Studio installed, make sure you have Android
47Studio 2.1 or higher by clicking <strong>Help > Check for Update</strong>
48(on Mac, <strong>Android Studio > Check for Updates</strong>).</p>
smain@google.comc4bb9a32016-03-08 13:27:37 -080049
smain@google.com04de2d22016-05-18 15:28:59 -070050<p>If you don't have it, <a href="{@docRoot}studio/">download Android Studio
smain@google.com8ac737d2016-04-22 15:27:28 -0700512.1 here</a>.</p>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080052
smain@google.com0a03f312016-03-07 16:38:37 -080053
54<h2 id="get-sdk">Get the N Preview SDK</h2>
55
smain@google.com67894042016-03-08 21:14:47 -080056<p>To start developing with Android N APIs, you need to install the
57Android N Preview SDK in Android Studio as follows:</p>
smain@google.com0a03f312016-03-07 16:38:37 -080058
59<ol>
smain@google.com8ac737d2016-04-22 15:27:28 -070060 <li>Open the SDK Manager by clicking <strong>Tools > Android >
61 SDK Manager</strong>.</li>
smain@google.com0a03f312016-03-07 16:38:37 -080062
smain@google.com8ac737d2016-04-22 15:27:28 -070063 <li>In the <strong>SDK Platforms</strong> tab, select the
smain@google.com0a03f312016-03-07 16:38:37 -080064 <strong>Android N Preview</strong> check box.</li>
65
66 <li>Click the <strong>SDK Tools</strong> tab, then select the
67 <strong>Android SDK Build Tools</strong>, <strong>Android SDK
68 Platform-Tools</strong>, and <strong>Android SDK Tools</strong> check
69 boxes.
70 </li>
71
72 <li>Click <strong>OK</strong>, then accept the licensing
73 agreements for any packages that need to be installed.
74 </li>
75</ol>
76
Joe Fernandez98b0ec62016-03-08 22:32:51 -080077<h3 id="docs-dl">Get the N Preview reference documentation</h3>
78
smain@google.comef11c2e2016-06-14 17:03:36 -070079<p>Beginning with the Preview 4 release, the API reference for the
80N platform (API level 24) is now available online at <a href=
Andrew Solovay9e9a3bb2016-06-09 13:06:30 -070081 "{@docRoot}reference/">developer.android.com/reference/</a>.
82</p>
83
smain@google.comef11c2e2016-06-14 17:03:36 -070084<p>If you'd like an offline copy of the API reference, you can download it
85from the following table. The download also includes an incremental diff report
86for API changes between the Preview 3 and Preview 4 release, which is not
87available online.</p>
Joe Fernandez98b0ec62016-03-08 22:32:51 -080088
89<table>
smain@google.com0a03f312016-03-07 16:38:37 -080090 <tr>
91 <th scope="col">Documentation</th>
92 <th scope="col">Checksums</th>
93 </tr>
94 <tr>
95 <td style="white-space: nowrap">
smain@google.comef11c2e2016-06-14 17:03:36 -070096 <a href="{@docRoot}shareables/preview/n-preview-4-docs.zip"
97 >n-preview-4-docs.zip</a></td>
smain@google.com0a03f312016-03-07 16:38:37 -080098 <td width="100%">
smain@google.comef11c2e2016-06-14 17:03:36 -070099 MD5: f853e3ba0707083336dfa780b8fed9a7<br>
100 SHA-1: 36fcbc497cc2e63b1bc1d629c304b0ba43a88946
smain@google.com0a03f312016-03-07 16:38:37 -0800101 </td>
102 </tr>
Amanda Kassayc68d8762016-05-25 20:59:53 +0000103</table>
smain@google.com0a03f312016-03-07 16:38:37 -0800104
105
106
Mary Yanchar1986a6e2016-03-30 13:56:12 -0700107<h2 id="java8">Get the Java 8 JDK</h2>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800108
Mary Yanchar1986a6e2016-03-30 13:56:12 -0700109<p>To compile your app against the Android N platform and use some tools with
110Android Studio 2.1, you need to install the Java 8 Developer Kit (JDK 8). So, if
111you don't already have the latest version, download JDK 8 now.</p>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800112
smain@google.coma329ffd2016-03-09 00:00:37 -0800113<p>Then set the JDK version in Android Studio as follows:</p>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800114
smain@google.com0a03f312016-03-07 16:38:37 -0800115<ol>
116 <li>Open an Android project in Android Studio, then open the
117 Project Structure dialog by selecting <strong>File &gt;
smain@google.coma329ffd2016-03-09 00:00:37 -0800118 Project Structure</strong>. (Alternatively, you can set the default
119 for all projects by selecting <strong>File &gt; Other Settings &gt;
120 Default Project Structure</strong>.)
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800121 </li>
122 <li>In the left panel of the dialog, click <strong>SDK Location</strong>.
123 </li>
124 <li>In the <strong>JDK Location</strong> field, enter the location of the
smain@google.coma329ffd2016-03-09 00:00:37 -0800125 Java 8 JDK (click the button on the right
126 to browse your files), then click <strong>OK</strong>.
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800127 </li>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800128</ol>
129
smain@google.coma329ffd2016-03-09 00:00:37 -0800130<img src="{@docRoot}preview/images/studio-jdk-location.jpg" width="700"
131 alt="" />
132
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800133
smain@google.com0a03f312016-03-07 16:38:37 -0800134<h2 id="create-update">Update or Create a Project</h2>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800135
smain@google.comef11c2e2016-06-14 17:03:36 -0700136<p>Now that the N platform API level is "24" instead
137of "N", you can configure your projects normally with this API level (and even
138publish your apps compiled with API 24 on Google Play). Just be sure that you've
139updated your project to use <strong>Android SDK Build Tools 24.0.0</strong> and
140<strong>Android SDK Platform-Tools 24.0.0</strong>.</p>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800141
smain@google.coma329ffd2016-03-09 00:00:37 -0800142<p>If you plan to use Java 8 language features, you should also read
143<a href="{@docRoot}preview/j8-jack.html">Java 8 Language Features</a>
144for information about the supported Java 8 features and
145how to configure your project with the Jack compiler.</p>
smain@google.com67894042016-03-08 21:14:47 -0800146
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800147
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800148<h3 id="update">Update an existing project</h3>
149
smain@google.com0a03f312016-03-07 16:38:37 -0800150<p>Open the
151 <code>build.gradle</code> file for your module and update the values as
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800152 follows:
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800153</p>
154
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800155<pre>
156android {
smain@google.comef11c2e2016-06-14 17:03:36 -0700157 compileSdkVersion <strong>24</strong>
158 buildToolsVersion <strong>'24.0.0'</strong>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800159 ...
160
161 defaultConfig {
smain@google.comef11c2e2016-06-14 17:03:36 -0700162 targetSdkVersion <strong>24</strong>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800163 ...
164 }
165 ...
166}</pre>
167
smain@google.comef11c2e2016-06-14 17:03:36 -0700168<p>Now that the API level 24 is final, you can compile against it and keep your
169<code>minSdkVersion</code> to whatever version is appropriate for your app.</p>
170
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800171
smain@google.com0a03f312016-03-07 16:38:37 -0800172<h3 id="create">Create a new project</h3>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800173
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800174
smain@google.com67894042016-03-08 21:14:47 -0800175<p>To create a new project for development with the Android N Preview SDK:</p>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800176
177<ol>
smain@google.com0a03f312016-03-07 16:38:37 -0800178 <li>Click <strong>File > New Project</strong>. and follow the steps until
smain@google.comef11c2e2016-06-14 17:03:36 -0700179 you reach the <strong>Target Android Devices</strong> page.
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800180 </li>
smain@google.comef11c2e2016-06-14 17:03:36 -0700181 <li>On this page, select the <strong>Phone and Tablet</strong> check box.</li>
smain@google.com0a03f312016-03-07 16:38:37 -0800182 <li>Under <strong>Phone and Tablet</strong> option, in the <strong>Minimum
183 SDK</strong> option list, select
smain@google.comef11c2e2016-06-14 17:03:36 -0700184 <strong>API 24: Android 6.X (N Preview)</strong>.</li>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800185</ol>
186
smain@google.com0a03f312016-03-07 16:38:37 -0800187
188<h2 id="next">Next Steps</h2>
189
smain@google.com67894042016-03-08 21:14:47 -0800190<ul>
191 <li>Follow the guide to <a
192href="{@docRoot}preview/download.html">Test on an Android N Device</a>.</li>
193 <li>Learn more about the Android N platform with
smain@google.com0a03f312016-03-07 16:38:37 -0800194<a href="{@docRoot}preview/behavior-changes.html">Behavior Changes</a>
195and <a href="{@docRoot}preview/api-overview.html">Android N APIs
smain@google.com67894042016-03-08 21:14:47 -0800196and Features</a>.</li>
197</ul>