Dirk Dougherty | 43eb951 | 2016-03-03 14:53:16 -0800 | [diff] [blame] | 1 | page.title=Set Up the SDK |
| 2 | meta.keywords="preview", "android" |
| 3 | page.tags="preview", "developer preview" |
| 4 | page.image=images/cards/card-n-sdk_2x.png |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 5 | |
| 6 | @jd:body |
| 7 | |
| 8 | |
| 9 | <div id="qv-wrapper"> |
| 10 | <div id="qv"> |
| 11 | <h2>In this document</h2> |
| 12 | <ol> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 13 | <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 Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 16 | <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 Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 22 | <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 Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 27 | |
| 28 | <p> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 29 | 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 Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 34 | </p> |
| 35 | |
| 36 | |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 37 | <h2 id="get-as13">Get Android Studio 2.1</h2> |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 38 | |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 39 | <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 Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 55 | |
| 56 | <ol> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 57 | <li>Download, install, and launch the current version of |
| 58 | <a href="{@docRoot}tools/studio/index.html">Android Studio</a>. |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 59 | </li> |
| 60 | |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 61 | <li>In Android Studio, open the <em>Settings</em> dialog and in the left |
| 62 | panel, choose <strong>Appearance & Behavior > System Settings > |
| 63 | Updates</strong>. |
| 64 | <ul> |
| 65 | <li>On Windows and Linux, open <em>Settings</em> by choosing |
| 66 | <strong>File > Settings</strong>. |
| 67 | </li> |
| 68 | <li>On Mac OS, open <em>Settings</em> by choosing |
| 69 | <strong>Android Studio > Preferences</strong>. |
| 70 | </li> |
| 71 | </ul> |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 72 | </li> |
| 73 | |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 74 | <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 Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 77 | </li> |
| 78 | |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 79 | <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 Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 82 | </li> |
| 83 | </ol> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 84 | |
| 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 > |
| 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 & Behavior > System Settings > |
| 122 | Updates</strong>. |
| 123 | <ul> |
| 124 | <li>On Windows and Linux, open <em>Settings</em> by choosing |
| 125 | <strong>File > Settings</strong>. |
| 126 | </li> |
| 127 | <li>On Mac OS, open <em>Settings</em> by choosing |
| 128 | <strong>Android Studio > 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 & Behavior > System Settings > |
| 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 Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 159 | |
| 160 | |
| 161 | <h2 id="create-update">Create or Update a Project</h2> |
| 162 | |
| 163 | <p> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 164 | In order to use the preview APIs, you must create or update a development |
| 165 | project to use the preview components. |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 166 | </p> |
| 167 | |
| 168 | |
| 169 | <h3 id="create">Create a new project</h3> |
| 170 | |
| 171 | <p> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 172 | 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 Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 175 | </p> |
| 176 | |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 177 | <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 Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 187 | |
| 188 | |
| 189 | <h3 id="update">Update an existing project</h3> |
| 190 | |
| 191 | <p> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 192 | 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 Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 196 | </p> |
| 197 | |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 198 | <pre> |
| 199 | android { |
| 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 Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 212 | |
| 213 | |
| 214 | <h2 id="setup-test">Set Up for Testing</h2> |
| 215 | |
| 216 | <p> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 217 | 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 Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 221 | </p> |
| 222 | |
| 223 | <h3 id="setup-device">Set up a physical device</h3> |
| 224 | |
| 225 | <p> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 226 | 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 Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 230 | </p> |
| 231 | |
| 232 | <p class="caution"> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 233 | <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 Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 236 | </p> |
| 237 | |
| 238 | <h3 id="setupAVD">Set up a virtual device</h3> |
| 239 | |
| 240 | <p> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 241 | 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 Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 243 | </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 Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 249 | in <a href="{@docRoot}preview/setup-sdk.html">Setting Up the Preview |
| 250 | SDK.</a></li> |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 251 | <li>Follow the steps in |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 252 | <a href="{@docRoot}tools/devices/managing-avds.html">Managing AVDs with AVD |
| 253 | Manager</a>. Use the following settings: |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 254 | <ul> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 255 | <li><strong>Device:</strong> |
| 256 | Nexus 5X, Nexus 6P, Nexus 9, or Android TV</li> |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 257 | <li><strong>Target:</strong> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 258 | Android N (Preview) - API Level N</li> |
| 259 | <li><strong>ABI:</strong> |
| 260 | x86</li> |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 261 | </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> |