blob: 7c6d251a7a7d33441b5f0c68bb7a551daccc6d5e [file] [log] [blame]
smain@google.com0a03f312016-03-07 16:38:37 -08001page.title=Set Up to Develop for the N 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>
13 <li><a href="#get-sdk">Get the N Preview SDK</a></li>
14 <li><a href="#java8">Get the Java 8 JDK and JRE</a></li>
15 <li><a href="#create-update">Update or Create a Project</a></li>
16 <li><a href="#next">Next Steps</a></li>
17</ol>
Dirk Dougherty5748bc42016-02-06 18:24:32 -080018 </div>
19</div>
20
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080021<p>
smain@google.com0a03f312016-03-07 16:38:37 -080022To develop apps for Android using new APIs in the N Preview and new language
23features of Java 8, you need to set up Android Studio 2.1 (preview) as described
24on this page.</p>
25
26<p>If you instead want to simply test your app's forward-compatibility on the
27Android N Preview system image, you can instead follow the guide to <a
28href="{@docRoot}preview/run-app.html">Run Your App on the N Preview</a>.</p>
29
30
31<h2 id="get-as13">Get Android Studio 2.1 (preview)</h2>
32
33<p>Developing for the Android N Preview platform requires Java 8 and a new
34compiler toolchain called JACK, which is currently supported only in
35Android Studio 2.1.
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080036</p>
Dirk Dougherty5748bc42016-02-06 18:24:32 -080037
smain@google.com0a03f312016-03-07 16:38:37 -080038<p>Android Studio 2.1 is currently available as a preview in the canary
39release channel&mdash;it is still in development. If you already
40have Android Studio and don't want to update to the canary channel, you can
41download Android Studio 2.1 as a separate installation and use it
42for use with the N Preview, leaving your primary Android Studio environment
43unaffected.</p>
Dirk Dougherty5748bc42016-02-06 18:24:32 -080044
smain@google.com0a03f312016-03-07 16:38:37 -080045<p>To download Android Studio 2.1 as a separate installation, follow these
46steps (or if you want to receive Android Studio 2.1 as an update to your
47existing installation, skip to step 4):</p>
Dirk Dougherty5748bc42016-02-06 18:24:32 -080048
49<ol>
smain@google.com0a03f312016-03-07 16:38:37 -080050 <li>Edit the name of your
51 existing Android Studio installation and append the version number. This way,
52 when you install the new version, it will not override the existing one.</li>
53 <li>Download the appropriate ZIP file for your operating system from the
54 <a href="http://tools.android.com/download/studio/canary/latest"
55 >canary channel download page</a>.
Dirk Dougherty5748bc42016-02-06 18:24:32 -080056 </li>
smain@google.com0a03f312016-03-07 16:38:37 -080057 <li>Unzip the package and move the Android Studio 2.1 contents to the
58 appropriate location for applications on your system, then launch it.</li>
59 <li>Open the Settings dialog
60 (<strong>File &gt; Settings</strong> on Windows/Linux, or
61 <strong>Android Studio &gt; Preferences</strong> on Mac). In the left
62 panel, select <strong>Appearance &amp; Behavior &gt; System Settings &gt;
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080063 Updates</strong>.
Dirk Dougherty5748bc42016-02-06 18:24:32 -080064 </li>
smain@google.com0a03f312016-03-07 16:38:37 -080065 <li>On the Updates panel, select the <strong>Automatically
66 check updates for</strong> check box and select
67 <strong>Canary Channel</strong> from the drop-down list.
Dirk Dougherty5748bc42016-02-06 18:24:32 -080068 </li>
69</ol>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080070
smain@google.com0a03f312016-03-07 16:38:37 -080071<p>Keep this settings window open for the next step.</p>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080072
smain@google.com0a03f312016-03-07 16:38:37 -080073
74<h2 id="get-sdk">Get the N Preview SDK</h2>
75
76<p>Now add the N Preview SDK to your Android Studio 2.1 development
77 environment as follows:</p>
78
79<ol>
80 <li>While still viewing the Updates panel from the previous
81 procedure, select the <strong>Automatically
82 check updates for Android SDK</strong> check box and select
83 <strong>Preview Channel</strong> from the drop-down list.
84 </li>
85 <li>Click <strong>Check Now</strong>.</li>
86
87 <li>In the left panel, select <strong>Appearance &amp; Behavior &gt;
88 System Settings &gt; Android SDK</strong>.
89
90 <li>Click the <strong>SDK Platforms</strong> tab, then select the
91 <strong>Android N Preview</strong> check box.</li>
92
93 <li>Click the <strong>SDK Tools</strong> tab, then select the
94 <strong>Android SDK Build Tools</strong>, <strong>Android SDK
95 Platform-Tools</strong>, and <strong>Android SDK Tools</strong> check
96 boxes.
97 </li>
98
99 <li>Click <strong>OK</strong>, then accept the licensing
100 agreements for any packages that need to be installed.
101 </li>
102</ol>
103
104<p>In addition to these preview components, you should download the
105N Preview developer docs from the following table. This is an offline version
106of the developer.android.com web site, except it includes the updated
107API reference for the N Preview APIs and an API difference report.</p>
108
109<table id="docs-dl">
110 <tr>
111 <th scope="col">Documentation</th>
112 <th scope="col">Checksums</th>
113 </tr>
114 <tr>
115 <td style="white-space: nowrap">
116 <a href="https://storage.googleapis.com/androiddevelopers/n-preview/n-preview-1-docs.zip"
117 >n-preview-1-docs.zip</a></td>
118 <td width="100%">
119 MD5: xxxx<br>
120 SHA-1: xxxx
121 </td>
122 </tr>
123<table>
124
125
126
127<h2 id="java8">Get the Java 8 JDK and JRE</h2>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800128
129<p>
smain@google.com0a03f312016-03-07 16:38:37 -0800130 The Java 8 Development Kit (JDK) is required to develop apps with the Android
131 N Preview, and the Java 8 Runtime Environment (JRE) is required to run some
132 tools included in Android Studio 2.1.
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800133</p>
smain@google.com0a03f312016-03-07 16:38:37 -0800134<p>So, if you don't have the latest version of each already,
135<a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html">download JDK 8</a> and
136<a href="http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html">download JRE 8</a> now.</p>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800137
smain@google.com0a03f312016-03-07 16:38:37 -0800138<p>With Java 8 installed, set the JDK version in Android Studio as follows:</p>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800139
smain@google.com0a03f312016-03-07 16:38:37 -0800140<ol>
141 <li>Open an Android project in Android Studio, then open the
142 Project Structure dialog by selecting <strong>File &gt;
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800143 Project Structure</strong>.
144 </li>
145 <li>In the left panel of the dialog, click <strong>SDK Location</strong>.
146 </li>
147 <li>In the <strong>JDK Location</strong> field, enter the location of the
smain@google.com0a03f312016-03-07 16:38:37 -0800148 Java 8 JDK, then click <strong>OK</strong>.
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800149 </li>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800150</ol>
151
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800152
smain@google.com0a03f312016-03-07 16:38:37 -0800153<h2 id="create-update">Update or Create a Project</h2>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800154
155<p>
smain@google.com0a03f312016-03-07 16:38:37 -0800156 To use the N Preview APIs, your project must be configured appropriately.
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800157</p>
158
159
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800160<h3 id="update">Update an existing project</h3>
161
smain@google.com0a03f312016-03-07 16:38:37 -0800162<p>Open the
163 <code>build.gradle</code> file for your module and update the values as
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800164 follows:
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800165</p>
166
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800167<pre>
168android {
169 compileSdkVersion <strong>'android-N'</strong>
smain@google.com0a03f312016-03-07 16:38:37 -0800170 buildToolsVersion <strong>24.0.0</strong>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800171 ...
172
173 defaultConfig {
174 ...
175 minSdkVersion <strong>'N'</strong>
176 targetSdkVersion <strong>'N'</strong>
177 ...
178 }
179 ...
180}</pre>
181
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800182
smain@google.com0a03f312016-03-07 16:38:37 -0800183<h3 id="create">Create a new project</h3>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800184
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800185
smain@google.com0a03f312016-03-07 16:38:37 -0800186<p>To create a new project for development with the N Preview SDK:</p>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800187
188<ol>
smain@google.com0a03f312016-03-07 16:38:37 -0800189 <li>Click <strong>File > New Project</strong>. and follow the steps until
190 you reach the Target Android Devices page.
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800191 </li>
smain@google.com0a03f312016-03-07 16:38:37 -0800192 <li>On this page, select <strong>Phone and Tablet</strong> option.</li>
193 <li>Under <strong>Phone and Tablet</strong> option, in the <strong>Minimum
194 SDK</strong> option list, select
195 <strong>N: Android API 23, N Preview (Preview)</strong>.</li>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800196</ol>
197
smain@google.com0a03f312016-03-07 16:38:37 -0800198
199<h2 id="next">Next Steps</h2>
200
201<p>Now that you've set up Android Studio 2.1 (preview), follow the guide
202to <a
203href="{@docRoot}preview/run-app.html">Run Your App on the N Preview</a>.
204And learn more about the Android N Preview platform with
205<a href="{@docRoot}preview/behavior-changes.html">Behavior Changes</a>
206and <a href="{@docRoot}preview/api-overview.html">Android N APIs
207and Features</a>.</p>
208