1 page.title=Set Up the Preview 2 meta.keywords="preview", "android" 3 page.tags="preview", "developer preview" 4 page.image=images/cards/card-n-sdk_2x.png 5 6 @jd:body 7 8 9 <div id="qv-wrapper"> 10 <div id="qv"> 11 <ol> 12 <li><a href="#get-as13">Get Android Studio 2.1</a></li> 13 <li><a href="#get-sdk">Get the Android N SDK</a> 14 <ol> 15 <li><a href="#docs-dl">Reference documentation</a> 16 </ol> 17 </li> 18 <li><a href="#java8">Get the Java 8 JDK</a></li> 19 <li><a href="#create-update">Update or Create a Project</a></li> 20 <li><a href="#next">Next Steps</a></li> 21 </ol> 22 </div> 23 </div> 24 25 <p>To develop apps for the Android N Preview, you need to make some updates 26 to your developer environment, as described on this page.</p> 27 28 <p>To simply test your app's compatibility on the 29 Android N system image, follow the guide to <a 30 href="{@docRoot}preview/download.html">Test on an Android N Device</a>.</p> 31 32 <img src="{@docRoot}preview/images/n-preview-setup.png" width="700" alt="" /> 33 34 35 <h2 id="get-as13">Get Android Studio 2.1</h2> 36 37 <p>The Android N platform adds support for <a 38 href="{@docRoot}preview/j8-jack.html">Java 8 language features</a>, 39 which require a new compiler called Jack. The latest version of Jack 40 is currently supported only in Android Studio 2.1. So if you want to 41 use Java 8 language features, you need to use Android Studio 2.1 to 42 build your app. Otherwise, you don't need to use the Jack compiler, but you 43 still need to update to JDK 8 to compile against the Android N platform, 44 as described below.</p> 45 46 <p>If you already have Android Studio installed, make sure you have Android 47 Studio 2.1 or higher by clicking <strong>Help > Check for Update</strong> 48 (on Mac, <strong>Android Studio > Check for Updates</strong>).</p> 49 50 <p>If you don't have it, <a href="{@docRoot}studio/">download Android Studio 51 2.1 here</a>.</p> 52 53 54 <h2 id="get-sdk">Get the N Preview SDK</h2> 55 56 <p>To start developing with Android N APIs, you need to install the 57 Android N Preview SDK in Android Studio as follows:</p> 58 59 <ol> 60 <li>Open the SDK Manager by clicking <strong>Tools > Android > 61 SDK Manager</strong>.</li> 62 63 <li>In the <strong>SDK Platforms</strong> tab, select the 64 <strong>Android N Preview</strong> check box.</li> 65 66 <li>Click the <strong>SDK Tools</strong> tab, then select the 67 <strong>Android SDK Build Tools</strong>, <strong>Android SDK 68 Platform-Tools</strong>, and <strong>Android SDK Tools</strong> check 69 boxes. 70 </li> 71 72 <li>Click <strong>OK</strong>, then accept the licensing 73 agreements for any packages that need to be installed. 74 </li> 75 </ol> 76 77 <h3 id="docs-dl">Get the N Preview reference documentation</h3> 78 79 <p>Beginning with the Preview 4 release, the API reference for the 80 N platform (API level 24) is now available online at <a href= 81 "{@docRoot}reference/">developer.android.com/reference/</a>. 82 </p> 83 84 <p>If you'd like an offline copy of the API reference, you can download it 85 from the following table. The download also includes an incremental diff report 86 for API changes between the Preview 3 and Preview 4 release, which is not 87 available online.</p> 88 89 <table> 90 <tr> 91 <th scope="col">Documentation</th> 92 <th scope="col">Checksums</th> 93 </tr> 94 <tr> 95 <td style="white-space: nowrap"> 96 <a href="{@docRoot}shareables/preview/n-preview-4-docs.zip" 97 >n-preview-4-docs.zip</a></td> 98 <td width="100%"> 99 MD5: f853e3ba0707083336dfa780b8fed9a7<br> 100 SHA-1: 36fcbc497cc2e63b1bc1d629c304b0ba43a88946 101 </td> 102 </tr> 103 </table> 104 105 106 107 <h2 id="java8">Get the Java 8 JDK</h2> 108 109 <p>To compile your app against the Android N platform and use some tools with 110 Android Studio 2.1, you need to install the Java 8 Developer Kit (JDK 8). So, if 111 you don't already have the latest version, download JDK 8 now.</p> 112 113 <p>Then set the JDK version in Android Studio as follows:</p> 114 115 <ol> 116 <li>Open an Android project in Android Studio, then open the 117 Project Structure dialog by selecting <strong>File > 118 Project Structure</strong>. (Alternatively, you can set the default 119 for all projects by selecting <strong>File > Other Settings > 120 Default Project Structure</strong>.) 121 </li> 122 <li>In the left panel of the dialog, click <strong>SDK Location</strong>. 123 </li> 124 <li>In the <strong>JDK Location</strong> field, enter the location of the 125 Java 8 JDK (click the button on the right 126 to browse your files), then click <strong>OK</strong>. 127 </li> 128 </ol> 129 130 <img src="{@docRoot}preview/images/studio-jdk-location.jpg" width="700" 131 alt="" /> 132 133 134 <h2 id="create-update">Update or Create a Project</h2> 135 136 <p>Now that the N platform API level is "24" instead 137 of "N", you can configure your projects normally with this API level (and even 138 publish your apps compiled with API 24 on Google Play). Just be sure that you've 139 updated your project to use <strong>Android SDK Build Tools 24.0.0</strong> and 140 <strong>Android SDK Platform-Tools 24.0.0</strong>.</p> 141 142 <p>If you plan to use Java 8 language features, you should also read 143 <a href="{@docRoot}preview/j8-jack.html">Java 8 Language Features</a> 144 for information about the supported Java 8 features and 145 how to configure your project with the Jack compiler.</p> 146 147 148 <h3 id="update">Update an existing project</h3> 149 150 <p>Open the 151 <code>build.gradle</code> file for your module and update the values as 152 follows: 153 </p> 154 155 <pre> 156 android { 157 compileSdkVersion <strong>24</strong> 158 buildToolsVersion <strong>'24.0.0'</strong> 159 ... 160 161 defaultConfig { 162 targetSdkVersion <strong>24</strong> 163 ... 164 } 165 ... 166 }</pre> 167 168 <p>Now that the API level 24 is final, you can compile against it and keep your 169 <code>minSdkVersion</code> to whatever version is appropriate for your app.</p> 170 171 172 <h3 id="create">Create a new project</h3> 173 174 175 <p>To create a new project for development with the Android N Preview SDK:</p> 176 177 <ol> 178 <li>Click <strong>File > New Project</strong>. and follow the steps until 179 you reach the <strong>Target Android Devices</strong> page. 180 </li> 181 <li>On this page, select the <strong>Phone and Tablet</strong> check box.</li> 182 <li>Under <strong>Phone and Tablet</strong> option, in the <strong>Minimum 183 SDK</strong> option list, select 184 <strong>API 24: Android 6.X (N Preview)</strong>.</li> 185 </ol> 186 187 188 <h2 id="next">Next Steps</h2> 189 190 <ul> 191 <li>Follow the guide to <a 192 href="{@docRoot}preview/download.html">Test on an Android N Device</a>.</li> 193 <li>Learn more about the Android N platform with 194 <a href="{@docRoot}preview/behavior-changes.html">Behavior Changes</a> 195 and <a href="{@docRoot}preview/api-overview.html">Android N APIs 196 and Features</a>.</li> 197 </ul> 198