blob: ea5eaf6a2c0d61e89e802d6b0e32bd932ddd7d98 [file] [log] [blame]
Dirk Dougherty43eb9512016-03-03 14:53:16 -08001page.title=Set Up the SDK
2meta.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">
11 <h2>In this document</h2>
12 <ol>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080013 <li><a href="#get-as13">Get Android Studio 2.1</a></li>
14 <li><a href="#get-sdk">Get the Preview SDK</a></li>
15 <li><a href="#java8">Get the Java 8 JDK</a></li>
Dirk Dougherty5748bc42016-02-06 18:24:32 -080016 <li><a href="#create-update">Create or Update a Project</a></li>
17 <li><a href="#setup-test">Set Up for Testing</a></li>
18 </ol>
19 </div>
20</div>
21
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080022<p>
23 You must have a development enviroment to make use of the Android N Developer
24 Preview. This document describes how to setup and configure a development
25 environment so you can use and test the Preview SDK.
26</p>
Dirk Dougherty5748bc42016-02-06 18:24:32 -080027
28<p>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080029 This document assumes that you are familiar with Android app development,
30 such as using the Android SDK Manager and creating projects. If you are new
31 to Android, see
32 <a href="{@docRoot}training/basics/firstapp/index.html">Building Your First
33 App</a> training lesson first.
Dirk Dougherty5748bc42016-02-06 18:24:32 -080034</p>
35
36
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080037<h2 id="get-as13">Get Android Studio 2.1</h2>
Dirk Dougherty5748bc42016-02-06 18:24:32 -080038
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080039<p>
40 The Developer Preview is best used with Android Studio 2.1, which is also in
41 preview status. If you have an existing version of Android Studio you are
42 using for development, you should install a separate instance of Android
43 Studio for use with the Preview. This section describes how to install
44 an instance of Android Studio and update to version 2.1.
45</p>
46
47<p class="caution">
48 <strong>Caution:</strong> The canary preview of Android Studio 2.1 is still
49 in active development. If you are using your primary development machine to
50 test the developer preview, you should create a second installation of
51 Android Studio to use for testing the Developer Preview.
52</p>
53
54<p>To install Android Studio and update to version 2.1:</p>
Dirk Dougherty5748bc42016-02-06 18:24:32 -080055
56<ol>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080057 <li>Download, install, and launch the current version of
58 <a href="{@docRoot}tools/studio/index.html">Android Studio</a>.
Dirk Dougherty5748bc42016-02-06 18:24:32 -080059 </li>
60
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080061 <li>In Android Studio, open the <em>Settings</em> dialog and in the left
62 panel, choose <strong>Appearance &amp; Behavior &gt; System Settings &gt;
63 Updates</strong>.
64 <ul>
65 <li>On Windows and Linux, open <em>Settings</em> by choosing
66 <strong>File &gt; Settings</strong>.
67 </li>
68 <li>On Mac OS, open <em>Settings</em> by choosing
69 <strong>Android Studio &gt; Preferences</strong>.
70 </li>
71 </ul>
Dirk Dougherty5748bc42016-02-06 18:24:32 -080072 </li>
73
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080074 <li>On the <em>Updates</em> panel, make sure the <strong>Automatically
75 check updates for</strong> option is selected and choose the
76 <strong>Canary Channel</strong> option.
Dirk Dougherty5748bc42016-02-06 18:24:32 -080077 </li>
78
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080079 <li>On the <em>Updates</em> panel, click <strong>Check Now</strong>
80 to check for the latest canary build. Allow the software to download
81 and install the canary version when prompted.
Dirk Dougherty5748bc42016-02-06 18:24:32 -080082 </li>
83</ol>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -080084
85
86<h2 id="java8">Get the Java 8 JDK</h2>
87
88<p>
89 You must use the Java 8 Development Kit with the N Developer Preview. If you
90 do not have this version of the JDK installed, download and install it before
91 working with the Preview SDK.
92</p>
93
94<p>To set the JDK version in Android Studio:</p>
95
96<ul>
97 <li>Make sure you have installed the Java 8 JDK, and make a note of its
98 directory location on your development computer.</li>
99 <li>With a development project open in Android Studio, open the
100 <em>Project Structure</em> dialog by choosing <strong>File &gt;
101 Project Structure</strong>.
102 </li>
103 <li>In the left panel of the dialog, click <strong>SDK Location</strong>.
104 </li>
105 <li>In the <strong>JDK Location</strong> field, enter the location of the
106 Java 8 JDK, and click <strong>OK</strong>.
107 </li>
108</ul>
109
110
111<h2 id="get-sdk">Get the Preview SDK</h2>
112
113<p>To add the Preview SDK to your Android Studio 2.1 development
114 environment:</p>
115
116<ol>
117 <li>Launch Android Studio 2.1.
118 </li>
119
120 <li>In Android Studio, open the <em>Settings</em> dialog and in the left
121 panel, choose <strong>Appearance &amp; Behavior &gt; System Settings &gt;
122 Updates</strong>.
123 <ul>
124 <li>On Windows and Linux, open <em>Settings</em> by choosing
125 <strong>File &gt; Settings</strong>.
126 </li>
127 <li>On Mac OS, open <em>Settings</em> by choosing
128 <strong>Android Studio &gt; Preferences</strong>.
129 </li>
130 </ul>
131 </li>
132
133 <li>On the <em>Updates</em> panel, make sure the <strong>Automatically
134 check updates for Android SDK</strong> option is selected and choose the
135 <strong>Preview Channel</strong> option.
136 </li>
137
138 <li>In the <em>Settings</em> dialog left panel, choose
139 <strong>Appearance &amp; Behavior &gt; System Settings &gt;
140 Android SDK</strong>.
141 </li>
142
143 <li>Click the <strong>SDK Platforms</strong> button, and then select
144 <strong>Android N Preview</strong>.
145 </li>
146
147 <li>Click the <strong>SDK Tools</strong> button, and select the latest
148 Android <strong>SDK Tools</strong>, <strong>Platform-tools</strong>, and
149 <strong>Build-tools</strong> versions.
150 </li>
151
152 <li>Click <strong>OK</strong> and then accept the licensing
153 agreements for the packages to be installed.
154 </li>
155</ol>
156
157<p>After completing these steps, the preview components are available in your
158 development environment. </p>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800159
160
161<h2 id="create-update">Create or Update a Project</h2>
162
163<p>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800164 In order to use the preview APIs, you must create or update a development
165 project to use the preview components.
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800166</p>
167
168
169<h3 id="create">Create a new project</h3>
170
171<p>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800172 Use the Android Studio new project wizard to create a project. For detailed
173 information on how to create a project with this too, see
174 <a href="{@docRoot}sdk/installing/create-project.html">Creating a Project</a>.
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800175</p>
176
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800177<p>To create a new project using the Preview SDK:</p>
178
179<ol>
180 <li>Start the New Project wizard and follow the steps until you reach the
181 <em>Target Android Devices</em> page.
182 </li>
183 <li>On this page, select <strong>Phone and Tablet</strong> option.</li>
184 <li>Under <strong>Phone and Tablet</strong> option, in the <strong>Minimum
185 SDK</strong> option list, select <strong>Android N Preview</strong>.</li>
186</ol>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800187
188
189<h3 id="update">Update an existing project</h3>
190
191<p>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800192 For existing projects, you must modify the project configuration to use the
193 Preview APIs. In your development environment, open the
194 <code>build.gradle</code> file for your module and set these values as
195 follows:
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800196</p>
197
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800198<pre>
199android {
200 compileSdkVersion <strong>'android-N'</strong>
201 ...
202
203 defaultConfig {
204 ...
205 minSdkVersion <strong>'N'</strong>
206 targetSdkVersion <strong>'N'</strong>
207 ...
208 }
209 ...
210}</pre>
211
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800212
213
214<h2 id="setup-test">Set Up for Testing</h2>
215
216<p>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800217 Testing an app with the preview requires that you have a device or virtual
218 device configured with the preview version of the platform. If you have a
219 compatible device, you can install the preview platform for testing.
220 Otherwise, you can configure a virtual device for testing.
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800221</p>
222
223<h3 id="setup-device">Set up a physical device</h3>
224
225<p>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800226 If you have a Nexus 5X, Nexus 6P, Nexus 9, or Nexus Player, you can install a
227 preview system image on these devices for testing your app. You can set up a
228 virtual device with the preview version of the platform from within Android
229 Studio using the Android Virtual Device Manager tool.
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800230</p>
231
232<p class="caution">
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800233 <strong>Important:</strong> Installing a preview image on a device
234 <em>removes all data from it</em>, so you should backup any data before
235 installing a preview image.
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800236</p>
237
238<h3 id="setupAVD">Set up a virtual device</h3>
239
240<p>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800241 You can set up virtual device with the preview version of the platform from
242 within Android Studio using the Android Virtual Device Manager tool.
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800243</p>
244
245<p>To create an AVD with the AVD Manager:</p>
246
247<ol>
248 <li>Install the Preview SDK in your development environment, as described
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800249 in <a href="{@docRoot}preview/setup-sdk.html">Setting Up the Preview
250 SDK.</a></li>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800251 <li>Follow the steps in
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800252 <a href="{@docRoot}tools/devices/managing-avds.html">Managing AVDs with AVD
253 Manager</a>. Use the following settings:
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800254 <ul>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800255 <li><strong>Device:</strong>
256 Nexus 5X, Nexus 6P, Nexus 9, or Android TV</li>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800257 <li><strong>Target:</strong>
Joe Fernandez7f94b7e2016-03-02 21:30:31 -0800258 Android N (Preview) - API Level N</li>
259 <li><strong>ABI:</strong>
260 x86</li>
Dirk Dougherty5748bc42016-02-06 18:24:32 -0800261 </ul>
262 </li>
263</ol>
264
265<p>
266 For more information about creating virtual devices for testing, see <a href=
267 "{@docRoot}tools/devices/index.html">Managing Virtual Devices</a>.
268</p>