blob: ff11e8e93c3f049e5677033cbe3330cec2750390 [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
Andrew Solovayb1b8cad2016-07-13 15:17:10 -070080 N platform (API level 24) is now available online at <a href=
81 "{@docRoot}reference/">developer.android.com/reference/</a>. There is also
82 an incremental diff report for <a href="{@docRoot}sdk/api_diff/24/changes.html"
83 >API changes between API levels 23 and 24</a>.</p>
smain@google.com0a03f312016-03-07 16:38:37 -080084
Mary Yanchar1986a6e2016-03-30 13:56:12 -070085<h2 id="java8">Get the Java 8 JDK</h2>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080086
Mary Yanchar1986a6e2016-03-30 13:56:12 -070087<p>To compile your app against the Android N platform and use some tools with
88Android Studio 2.1, you need to install the Java 8 Developer Kit (JDK 8). So, if
89you don't already have the latest version, download JDK 8 now.</p>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080090
smain@google.coma329ffd2016-03-09 00:00:37 -080091<p>Then set the JDK version in Android Studio as follows:</p>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080092
smain@google.com0a03f312016-03-07 16:38:37 -080093<ol>
94 <li>Open an Android project in Android Studio, then open the
95 Project Structure dialog by selecting <strong>File &gt;
smain@google.coma329ffd2016-03-09 00:00:37 -080096 Project Structure</strong>. (Alternatively, you can set the default
97 for all projects by selecting <strong>File &gt; Other Settings &gt;
98 Default Project Structure</strong>.)
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080099 </li>
100 <li>In the left panel of the dialog, click <strong>SDK Location</strong>.
101 </li>
102 <li>In the <strong>JDK Location</strong> field, enter the location of the
smain@google.coma329ffd2016-03-09 00:00:37 -0800103 Java 8 JDK (click the button on the right
104 to browse your files), then click <strong>OK</strong>.
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800105 </li>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800106</ol>
107
smain@google.coma329ffd2016-03-09 00:00:37 -0800108<img src="{@docRoot}preview/images/studio-jdk-location.jpg" width="700"
109 alt="" />
110
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800111
smain@google.com0a03f312016-03-07 16:38:37 -0800112<h2 id="create-update">Update or Create a Project</h2>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800113
smain@google.comef11c2e2016-06-14 17:03:36 -0700114<p>Now that the N platform API level is "24" instead
115of "N", you can configure your projects normally with this API level (and even
116publish your apps compiled with API 24 on Google Play). Just be sure that you've
117updated your project to use <strong>Android SDK Build Tools 24.0.0</strong> and
118<strong>Android SDK Platform-Tools 24.0.0</strong>.</p>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800119
smain@google.coma329ffd2016-03-09 00:00:37 -0800120<p>If you plan to use Java 8 language features, you should also read
121<a href="{@docRoot}preview/j8-jack.html">Java 8 Language Features</a>
122for information about the supported Java 8 features and
123how to configure your project with the Jack compiler.</p>
smain@google.com67894042016-03-08 21:14:47 -0800124
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800125
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800126<h3 id="update">Update an existing project</h3>
127
smain@google.com0a03f312016-03-07 16:38:37 -0800128<p>Open the
129 <code>build.gradle</code> file for your module and update the values as
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800130 follows:
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800131</p>
132
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800133<pre>
134android {
smain@google.comef11c2e2016-06-14 17:03:36 -0700135 compileSdkVersion <strong>24</strong>
136 buildToolsVersion <strong>'24.0.0'</strong>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800137 ...
138
139 defaultConfig {
smain@google.comef11c2e2016-06-14 17:03:36 -0700140 targetSdkVersion <strong>24</strong>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800141 ...
142 }
143 ...
144}</pre>
145
smain@google.comef11c2e2016-06-14 17:03:36 -0700146<p>Now that the API level 24 is final, you can compile against it and keep your
147<code>minSdkVersion</code> to whatever version is appropriate for your app.</p>
148
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800149
smain@google.com0a03f312016-03-07 16:38:37 -0800150<h3 id="create">Create a new project</h3>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800151
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800152
smain@google.com67894042016-03-08 21:14:47 -0800153<p>To create a new project for development with the Android N Preview SDK:</p>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800154
155<ol>
smain@google.com0a03f312016-03-07 16:38:37 -0800156 <li>Click <strong>File > New Project</strong>. and follow the steps until
smain@google.comef11c2e2016-06-14 17:03:36 -0700157 you reach the <strong>Target Android Devices</strong> page.
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800158 </li>
smain@google.comef11c2e2016-06-14 17:03:36 -0700159 <li>On this page, select the <strong>Phone and Tablet</strong> check box.</li>
smain@google.com0a03f312016-03-07 16:38:37 -0800160 <li>Under <strong>Phone and Tablet</strong> option, in the <strong>Minimum
161 SDK</strong> option list, select
smain@google.comef11c2e2016-06-14 17:03:36 -0700162 <strong>API 24: Android 6.X (N Preview)</strong>.</li>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800163</ol>
164
smain@google.com0a03f312016-03-07 16:38:37 -0800165
166<h2 id="next">Next Steps</h2>
167
smain@google.com67894042016-03-08 21:14:47 -0800168<ul>
169 <li>Follow the guide to <a
170href="{@docRoot}preview/download.html">Test on an Android N Device</a>.</li>
171 <li>Learn more about the Android N platform with
smain@google.com0a03f312016-03-07 16:38:37 -0800172<a href="{@docRoot}preview/behavior-changes.html">Behavior Changes</a>
173and <a href="{@docRoot}preview/api-overview.html">Android N APIs
smain@google.com67894042016-03-08 21:14:47 -0800174and Features</a>.</li>
175</ul>