David Friedman | fffa8ac | 2016-03-07 22:13:29 -0800 | [diff] [blame] | 1 | page.title=Set Up to Develop for Android N |
Dirk Dougherty | 43eb951 | 2016-03-03 14:53:16 -0800 | [diff] [blame] | 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"> |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 11 | <ol> |
| 12 | <li><a href="#get-as13">Get Android Studio 2.1</a></li> |
David Friedman | fffa8ac | 2016-03-07 22:13:29 -0800 | [diff] [blame] | 13 | <li><a href="#get-sdk">Get the Android N SDK</a></li> |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 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 Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 18 | </div> |
| 19 | </div> |
| 20 | |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 21 | <p> |
David Friedman | fffa8ac | 2016-03-07 22:13:29 -0800 | [diff] [blame] | 22 | To develop apps for Android using new APIs in Android N and new language |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 23 | features of Java 8, you need to set up Android Studio 2.1 (preview) as described |
| 24 | on this page.</p> |
| 25 | |
| 26 | <p>If you instead want to simply test your app's forward-compatibility on the |
David Friedman | fffa8ac | 2016-03-07 22:13:29 -0800 | [diff] [blame] | 27 | Android N system image, you can instead follow the guide to <a |
smain@google.com | 3254f8c | 2016-03-08 17:25:50 -0800 | [diff] [blame] | 28 | href="{@docRoot}preview/download.html">Test on an Android N Device</a>.</p> |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 29 | |
| 30 | |
smain@google.com | 02573e0 | 2016-03-08 18:42:51 -0800 | [diff] [blame^] | 31 | <img src="{@docRoot}preview/images/n-preview-setup.png" width="700" alt="" /> |
| 32 | |
| 33 | |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 34 | <h2 id="get-as13">Get Android Studio 2.1 (preview)</h2> |
| 35 | |
David Friedman | fffa8ac | 2016-03-07 22:13:29 -0800 | [diff] [blame] | 36 | <p>Developing for the Android N platform requires Java 8 and a new |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 37 | compiler toolchain called JACK, which is currently supported only in |
| 38 | Android Studio 2.1. |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 39 | </p> |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 40 | |
smain@google.com | c4bb9a3 | 2016-03-08 13:27:37 -0800 | [diff] [blame] | 41 | <iframe width="400" height="225" src="//www.youtube.com/embed/SBbWGxXCMqQ?autohide=1&showinfo=0" frameborder="0" allowfullscreen="" style="float: right; margin: 0 0 20px 20px;"></iframe> |
| 42 | |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 43 | <p>Android Studio 2.1 is currently available as a preview in the canary |
smain@google.com | c4bb9a3 | 2016-03-08 13:27:37 -0800 | [diff] [blame] | 44 | release channel. If you already |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 45 | have Android Studio and don't want to update to the canary channel, you can |
| 46 | download Android Studio 2.1 as a separate installation and use it |
David Friedman | fffa8ac | 2016-03-07 22:13:29 -0800 | [diff] [blame] | 47 | with Android N, leaving your primary Android Studio environment |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 48 | unaffected.</p> |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 49 | |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 50 | <p>To download Android Studio 2.1 as a separate installation, follow these |
| 51 | steps (or if you want to receive Android Studio 2.1 as an update to your |
| 52 | existing installation, skip to step 4):</p> |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 53 | |
| 54 | <ol> |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 55 | <li>Edit the name of your |
| 56 | existing Android Studio installation and append the version number. This way, |
| 57 | when you install the new version, it will not override the existing one.</li> |
| 58 | <li>Download the appropriate ZIP file for your operating system from the |
| 59 | <a href="http://tools.android.com/download/studio/canary/latest" |
| 60 | >canary channel download page</a>. |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 61 | </li> |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 62 | <li>Unzip the package and move the Android Studio 2.1 contents to the |
| 63 | appropriate location for applications on your system, then launch it.</li> |
| 64 | <li>Open the Settings dialog |
| 65 | (<strong>File > Settings</strong> on Windows/Linux, or |
| 66 | <strong>Android Studio > Preferences</strong> on Mac). In the left |
| 67 | panel, select <strong>Appearance & Behavior > System Settings > |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 68 | Updates</strong>. |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 69 | </li> |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 70 | <li>On the Updates panel, select the <strong>Automatically |
| 71 | check updates for</strong> check box and select |
| 72 | <strong>Canary Channel</strong> from the drop-down list. |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 73 | </li> |
| 74 | </ol> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 75 | |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 76 | <p>Keep this settings window open for the next step.</p> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 77 | |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 78 | |
| 79 | <h2 id="get-sdk">Get the N Preview SDK</h2> |
| 80 | |
| 81 | <p>Now add the N Preview SDK to your Android Studio 2.1 development |
| 82 | environment as follows:</p> |
| 83 | |
| 84 | <ol> |
| 85 | <li>While still viewing the Updates panel from the previous |
| 86 | procedure, select the <strong>Automatically |
| 87 | check updates for Android SDK</strong> check box and select |
| 88 | <strong>Preview Channel</strong> from the drop-down list. |
| 89 | </li> |
| 90 | <li>Click <strong>Check Now</strong>.</li> |
| 91 | |
| 92 | <li>In the left panel, select <strong>Appearance & Behavior > |
| 93 | System Settings > Android SDK</strong>. |
| 94 | |
| 95 | <li>Click the <strong>SDK Platforms</strong> tab, then select the |
| 96 | <strong>Android N Preview</strong> check box.</li> |
| 97 | |
| 98 | <li>Click the <strong>SDK Tools</strong> tab, then select the |
| 99 | <strong>Android SDK Build Tools</strong>, <strong>Android SDK |
| 100 | Platform-Tools</strong>, and <strong>Android SDK Tools</strong> check |
| 101 | boxes. |
| 102 | </li> |
| 103 | |
| 104 | <li>Click <strong>OK</strong>, then accept the licensing |
| 105 | agreements for any packages that need to be installed. |
| 106 | </li> |
| 107 | </ol> |
| 108 | |
| 109 | <p>In addition to these preview components, you should download the |
| 110 | N Preview developer docs from the following table. This is an offline version |
| 111 | of the developer.android.com web site, except it includes the updated |
David Friedman | fffa8ac | 2016-03-07 22:13:29 -0800 | [diff] [blame] | 112 | API reference for the Android N APIs and an API difference report.</p> |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 113 | |
| 114 | <table id="docs-dl"> |
| 115 | <tr> |
| 116 | <th scope="col">Documentation</th> |
| 117 | <th scope="col">Checksums</th> |
| 118 | </tr> |
| 119 | <tr> |
| 120 | <td style="white-space: nowrap"> |
Joe Fernandez | 49b5ead | 2016-03-08 18:35:18 -0800 | [diff] [blame] | 121 | <a href="{@docRoot}shareables/preview/n-preview-1-docs.zip" |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 122 | >n-preview-1-docs.zip</a></td> |
| 123 | <td width="100%"> |
Joe Fernandez | 82211ee | 2016-03-08 16:44:08 -0800 | [diff] [blame] | 124 | MD5: 129c447102a9f1fb3712234e5268a708<br> |
| 125 | SHA-1: 2200b3b530ed15c8d48f768d6b00d2082d01c9c5 |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 126 | </td> |
| 127 | </tr> |
| 128 | <table> |
| 129 | |
| 130 | |
| 131 | |
| 132 | <h2 id="java8">Get the Java 8 JDK and JRE</h2> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 133 | |
| 134 | <p> |
David Friedman | fffa8ac | 2016-03-07 22:13:29 -0800 | [diff] [blame] | 135 | The Java 8 Development Kit (JDK) is required to develop apps with Android |
| 136 | N, and the Java 8 Runtime Environment (JRE) is required to run some |
Joe Fernandez | 82211ee | 2016-03-08 16:44:08 -0800 | [diff] [blame] | 137 | tools included in Android Studio 2.1. So, if you don't have the latest |
| 138 | version of each already, download JDK 8 and download JRE 8 now.</p> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 139 | |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 140 | <p>With Java 8 installed, set the JDK version in Android Studio as follows:</p> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 141 | |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 142 | <ol> |
| 143 | <li>Open an Android project in Android Studio, then open the |
| 144 | Project Structure dialog by selecting <strong>File > |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 145 | Project Structure</strong>. |
| 146 | </li> |
| 147 | <li>In the left panel of the dialog, click <strong>SDK Location</strong>. |
| 148 | </li> |
| 149 | <li>In the <strong>JDK Location</strong> field, enter the location of the |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 150 | Java 8 JDK, then click <strong>OK</strong>. |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 151 | </li> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 152 | </ol> |
| 153 | |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 154 | |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 155 | <h2 id="create-update">Update or Create a Project</h2> |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 156 | |
| 157 | <p> |
David Friedman | fffa8ac | 2016-03-07 22:13:29 -0800 | [diff] [blame] | 158 | To use the Android N APIs, your project must be configured appropriately. |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 159 | </p> |
| 160 | |
| 161 | |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 162 | <h3 id="update">Update an existing project</h3> |
| 163 | |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 164 | <p>Open the |
| 165 | <code>build.gradle</code> file for your module and update the values as |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 166 | follows: |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 167 | </p> |
| 168 | |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 169 | <pre> |
| 170 | android { |
| 171 | compileSdkVersion <strong>'android-N'</strong> |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 172 | buildToolsVersion <strong>24.0.0</strong> |
Joe Fernandez | 7f94b7e | 2016-03-02 21:30:31 -0800 | [diff] [blame] | 173 | ... |
| 174 | |
| 175 | defaultConfig { |
| 176 | ... |
| 177 | minSdkVersion <strong>'N'</strong> |
| 178 | targetSdkVersion <strong>'N'</strong> |
| 179 | ... |
| 180 | } |
| 181 | ... |
| 182 | }</pre> |
| 183 | |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 184 | |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 185 | <h3 id="create">Create a new project</h3> |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 186 | |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 187 | |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 188 | <p>To create a new project for development with the N Preview SDK:</p> |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 189 | |
| 190 | <ol> |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 191 | <li>Click <strong>File > New Project</strong>. and follow the steps until |
| 192 | you reach the Target Android Devices page. |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 193 | </li> |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 194 | <li>On this page, select <strong>Phone and Tablet</strong> option.</li> |
| 195 | <li>Under <strong>Phone and Tablet</strong> option, in the <strong>Minimum |
| 196 | SDK</strong> option list, select |
| 197 | <strong>N: Android API 23, N Preview (Preview)</strong>.</li> |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 198 | </ol> |
| 199 | |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 200 | |
| 201 | <h2 id="next">Next Steps</h2> |
| 202 | |
| 203 | <p>Now that you've set up Android Studio 2.1 (preview), follow the guide |
| 204 | to <a |
smain@google.com | 3254f8c | 2016-03-08 17:25:50 -0800 | [diff] [blame] | 205 | href="{@docRoot}preview/download.html">Test on an Android N Device</a>. |
Joe Fernandez | 82211ee | 2016-03-08 16:44:08 -0800 | [diff] [blame] | 206 | And learn more about the Android N platform with |
smain@google.com | 0a03f31 | 2016-03-07 16:38:37 -0800 | [diff] [blame] | 207 | <a href="{@docRoot}preview/behavior-changes.html">Behavior Changes</a> |
| 208 | and <a href="{@docRoot}preview/api-overview.html">Android N APIs |
| 209 | and Features</a>.</p> |
| 210 | |