blob: 4099f3e481345cbaf3b287ecfb972beb2f6c4049 [file] [log] [blame]
David Friedmanfffa8ac2016-03-07 22:13:29 -08001page.title=Set Up to Develop for Android N
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>
David Friedmanfffa8ac2016-03-07 22:13:29 -080013 <li><a href="#get-sdk">Get the Android N SDK</a></li>
smain@google.com0a03f312016-03-07 16:38:37 -080014 <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>
David Friedmanfffa8ac2016-03-07 22:13:29 -080022To develop apps for Android using new APIs in Android N and new language
smain@google.com0a03f312016-03-07 16:38:37 -080023features 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
David Friedmanfffa8ac2016-03-07 22:13:29 -080027Android N system image, you can instead follow the guide to <a
smain@google.com3254f8c2016-03-08 17:25:50 -080028href="{@docRoot}preview/download.html">Test on an Android N Device</a>.</p>
smain@google.com0a03f312016-03-07 16:38:37 -080029
30
31<h2 id="get-as13">Get Android Studio 2.1 (preview)</h2>
32
David Friedmanfffa8ac2016-03-07 22:13:29 -080033<p>Developing for the Android N platform requires Java 8 and a new
smain@google.com0a03f312016-03-07 16:38:37 -080034compiler 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.comc4bb9a32016-03-08 13:27:37 -080038<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>
39
smain@google.com0a03f312016-03-07 16:38:37 -080040<p>Android Studio 2.1 is currently available as a preview in the canary
smain@google.comc4bb9a32016-03-08 13:27:37 -080041release channel. If you already
smain@google.com0a03f312016-03-07 16:38:37 -080042have Android Studio and don't want to update to the canary channel, you can
43download Android Studio 2.1 as a separate installation and use it
David Friedmanfffa8ac2016-03-07 22:13:29 -080044with Android N, leaving your primary Android Studio environment
smain@google.com0a03f312016-03-07 16:38:37 -080045unaffected.</p>
Dirk Dougherty5748bc42016-02-06 18:24:32 -080046
smain@google.com0a03f312016-03-07 16:38:37 -080047<p>To download Android Studio 2.1 as a separate installation, follow these
48steps (or if you want to receive Android Studio 2.1 as an update to your
49existing installation, skip to step 4):</p>
Dirk Dougherty5748bc42016-02-06 18:24:32 -080050
51<ol>
smain@google.com0a03f312016-03-07 16:38:37 -080052 <li>Edit the name of your
53 existing Android Studio installation and append the version number. This way,
54 when you install the new version, it will not override the existing one.</li>
55 <li>Download the appropriate ZIP file for your operating system from the
56 <a href="http://tools.android.com/download/studio/canary/latest"
57 >canary channel download page</a>.
Dirk Dougherty5748bc42016-02-06 18:24:32 -080058 </li>
smain@google.com0a03f312016-03-07 16:38:37 -080059 <li>Unzip the package and move the Android Studio 2.1 contents to the
60 appropriate location for applications on your system, then launch it.</li>
61 <li>Open the Settings dialog
62 (<strong>File &gt; Settings</strong> on Windows/Linux, or
63 <strong>Android Studio &gt; Preferences</strong> on Mac). In the left
64 panel, select <strong>Appearance &amp; Behavior &gt; System Settings &gt;
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080065 Updates</strong>.
Dirk Dougherty5748bc42016-02-06 18:24:32 -080066 </li>
smain@google.com0a03f312016-03-07 16:38:37 -080067 <li>On the Updates panel, select the <strong>Automatically
68 check updates for</strong> check box and select
69 <strong>Canary Channel</strong> from the drop-down list.
Dirk Dougherty5748bc42016-02-06 18:24:32 -080070 </li>
71</ol>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080072
smain@google.com0a03f312016-03-07 16:38:37 -080073<p>Keep this settings window open for the next step.</p>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080074
smain@google.com0a03f312016-03-07 16:38:37 -080075
76<h2 id="get-sdk">Get the N Preview SDK</h2>
77
78<p>Now add the N Preview SDK to your Android Studio 2.1 development
79 environment as follows:</p>
80
81<ol>
82 <li>While still viewing the Updates panel from the previous
83 procedure, select the <strong>Automatically
84 check updates for Android SDK</strong> check box and select
85 <strong>Preview Channel</strong> from the drop-down list.
86 </li>
87 <li>Click <strong>Check Now</strong>.</li>
88
89 <li>In the left panel, select <strong>Appearance &amp; Behavior &gt;
90 System Settings &gt; Android SDK</strong>.
91
92 <li>Click the <strong>SDK Platforms</strong> tab, then select the
93 <strong>Android N Preview</strong> check box.</li>
94
95 <li>Click the <strong>SDK Tools</strong> tab, then select the
96 <strong>Android SDK Build Tools</strong>, <strong>Android SDK
97 Platform-Tools</strong>, and <strong>Android SDK Tools</strong> check
98 boxes.
99 </li>
100
101 <li>Click <strong>OK</strong>, then accept the licensing
102 agreements for any packages that need to be installed.
103 </li>
104</ol>
105
106<p>In addition to these preview components, you should download the
107N Preview developer docs from the following table. This is an offline version
108of the developer.android.com web site, except it includes the updated
David Friedmanfffa8ac2016-03-07 22:13:29 -0800109API reference for the Android N APIs and an API difference report.</p>
smain@google.com0a03f312016-03-07 16:38:37 -0800110
111<table id="docs-dl">
112 <tr>
113 <th scope="col">Documentation</th>
114 <th scope="col">Checksums</th>
115 </tr>
116 <tr>
117 <td style="white-space: nowrap">
Joe Fernandez82211ee2016-03-08 16:44:08 -0800118 <a href="https://storage.googleapis.com/androiddevelopers/preview/n-preview-1-docs.zip"
smain@google.com0a03f312016-03-07 16:38:37 -0800119 >n-preview-1-docs.zip</a></td>
120 <td width="100%">
Joe Fernandez82211ee2016-03-08 16:44:08 -0800121 MD5: 129c447102a9f1fb3712234e5268a708<br>
122 SHA-1: 2200b3b530ed15c8d48f768d6b00d2082d01c9c5
smain@google.com0a03f312016-03-07 16:38:37 -0800123 </td>
124 </tr>
125<table>
126
127
128
129<h2 id="java8">Get the Java 8 JDK and JRE</h2>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800130
131<p>
David Friedmanfffa8ac2016-03-07 22:13:29 -0800132 The Java 8 Development Kit (JDK) is required to develop apps with Android
133 N, and the Java 8 Runtime Environment (JRE) is required to run some
Joe Fernandez82211ee2016-03-08 16:44:08 -0800134 tools included in Android Studio 2.1. So, if you don't have the latest
135 version of each already, download JDK 8 and download JRE 8 now.</p>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800136
smain@google.com0a03f312016-03-07 16:38:37 -0800137<p>With Java 8 installed, set the JDK version in Android Studio as follows:</p>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800138
smain@google.com0a03f312016-03-07 16:38:37 -0800139<ol>
140 <li>Open an Android project in Android Studio, then open the
141 Project Structure dialog by selecting <strong>File &gt;
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800142 Project Structure</strong>.
143 </li>
144 <li>In the left panel of the dialog, click <strong>SDK Location</strong>.
145 </li>
146 <li>In the <strong>JDK Location</strong> field, enter the location of the
smain@google.com0a03f312016-03-07 16:38:37 -0800147 Java 8 JDK, then click <strong>OK</strong>.
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800148 </li>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800149</ol>
150
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800151
smain@google.com0a03f312016-03-07 16:38:37 -0800152<h2 id="create-update">Update or Create a Project</h2>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800153
154<p>
David Friedmanfffa8ac2016-03-07 22:13:29 -0800155 To use the Android N APIs, your project must be configured appropriately.
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800156</p>
157
158
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800159<h3 id="update">Update an existing project</h3>
160
smain@google.com0a03f312016-03-07 16:38:37 -0800161<p>Open the
162 <code>build.gradle</code> file for your module and update the values as
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800163 follows:
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800164</p>
165
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800166<pre>
167android {
168 compileSdkVersion <strong>'android-N'</strong>
smain@google.com0a03f312016-03-07 16:38:37 -0800169 buildToolsVersion <strong>24.0.0</strong>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800170 ...
171
172 defaultConfig {
173 ...
174 minSdkVersion <strong>'N'</strong>
175 targetSdkVersion <strong>'N'</strong>
176 ...
177 }
178 ...
179}</pre>
180
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800181
smain@google.com0a03f312016-03-07 16:38:37 -0800182<h3 id="create">Create a new project</h3>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800183
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800184
smain@google.com0a03f312016-03-07 16:38:37 -0800185<p>To create a new project for development with the N Preview SDK:</p>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800186
187<ol>
smain@google.com0a03f312016-03-07 16:38:37 -0800188 <li>Click <strong>File > New Project</strong>. and follow the steps until
189 you reach the Target Android Devices page.
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800190 </li>
smain@google.com0a03f312016-03-07 16:38:37 -0800191 <li>On this page, select <strong>Phone and Tablet</strong> option.</li>
192 <li>Under <strong>Phone and Tablet</strong> option, in the <strong>Minimum
193 SDK</strong> option list, select
194 <strong>N: Android API 23, N Preview (Preview)</strong>.</li>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800195</ol>
196
smain@google.com0a03f312016-03-07 16:38:37 -0800197
198<h2 id="next">Next Steps</h2>
199
200<p>Now that you've set up Android Studio 2.1 (preview), follow the guide
201to <a
smain@google.com3254f8c2016-03-08 17:25:50 -0800202href="{@docRoot}preview/download.html">Test on an Android N Device</a>.
Joe Fernandez82211ee2016-03-08 16:44:08 -0800203And learn more about the Android N platform with
smain@google.com0a03f312016-03-07 16:38:37 -0800204<a href="{@docRoot}preview/behavior-changes.html">Behavior Changes</a>
205and <a href="{@docRoot}preview/api-overview.html">Android N APIs
206and Features</a>.</p>
207