Dirk Dougherty | 7470945 | 2015-05-15 00:51:24 -0700 | [diff] [blame] | 1 | page.title=Set Up the Preview SDK |
| 2 | page.image=images/cards/card-set-up_16-9_2x.png |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 3 | |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 4 | @jd:body |
| 5 | |
| 6 | |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 7 | <div id="qv-wrapper"> |
| 8 | <div id="qv"> |
| 9 | <h2>In this document</h2> |
| 10 | <ol> |
| 11 | <li><a href="#get-sdk">Get the Preview SDK</a></li> |
| 12 | <li><a href="#create-update">Create or Update a Project</a></li> |
| 13 | <li><a href="#setup-test">Set Up for Testing</a></li> |
| 14 | </ol> |
| 15 | </div> |
| 16 | </div> |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 17 | |
| 18 | <p>The Preview SDK is available from the Android SDK Manager. |
| 19 | This document assumes that you are familiar with Android app development, such |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 20 | as using the Android SDK Manager and creating projects. If you are new to |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 21 | Android, see <a href="{@docRoot}training/basics/firstapp/index.html">Building Your First |
| 22 | App</a> training lesson first.</a></p> |
| 23 | |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 24 | <h2 id="get-sdk">Get the Preview SDK</h2> |
| 25 | |
| 26 | <p>To add the Android Preview SDK components to your development environment:</p> |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 27 | |
| 28 | <ol> |
| 29 | <li>Start the <a href="{@docRoot}tools/help/sdk-manager.html">Android SDK Manager</a>.</li> |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 30 | <li>In the <strong>Tools</strong> section, select the latest Android <strong>SDK Tools</strong>, |
| 31 | <strong>Platform-tools</strong>, and <strong>Build-tools</strong>.</li> |
| 32 | <li>Select everything under the <strong>Android M Developer Preview</strong> section and |
| 33 | click <strong>Install packages...</strong></li> |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 34 | <li>Accept the Licensing Agreement for all of the packages and click |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 35 | <strong>Install</strong>.</li> |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 36 | </ol> |
| 37 | |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 38 | <p>After completing these steps, the preview components are available in your development |
| 39 | environment. </p> |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 40 | |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 41 | |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 42 | <h2 id="create-update">Create or Update a Project</h2> |
| 43 | |
| 44 | <p> |
| 45 | In order to use the preview APIs, you must create or update a development project to use |
| 46 | the preview components. |
| 47 | </p> |
| 48 | |
| 49 | |
| 50 | <h3 id="create">Create a new project</h3> |
| 51 | |
| 52 | <p> |
| 53 | We recommend using Android Studio for create a project with the preview. Follow the steps |
| 54 | described in <a href="{@docRoot}sdk/installing/create-project.html">Creating a Project</a> |
| 55 | until you arrive at the <em>Form Factors</em> screen in the project wizard. Then perform |
| 56 | the following steps to create a project configured for the preview. |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 57 | </p> |
| 58 | |
| 59 | <ul> |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 60 | <li>Check <strong>Phone and Tablet</strong>.</li> |
| 61 | <li>Select <strong>API 22+: Android M (Preview)</strong> in <strong>Minimum SDK</strong>.</li> |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 62 | </ul> |
| 63 | |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 64 | |
| 65 | <h3 id="update">Update an existing project</h3> |
| 66 | |
| 67 | <p> |
| 68 | For existing projects, you must modify the project configuration to enable the preview APIs. In |
| 69 | your the development environment, open the <code>build.gradle</code> file for your module and |
| 70 | set these values as follows: |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 71 | </p> |
| 72 | |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 73 | <ul> |
| 74 | <li><code>compileSdkVersion</code> is set to <code>'android-MNC'</code></li> |
| 75 | <li><code>minSdkVersion</code> is set to <code>'android-MNC'</code></li> |
| 76 | <li><code>targetSdkVersion</code> is set to <code>'android-MNC'</code></li> |
| 77 | </ul> |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 78 | |
| 79 | |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 80 | <h2 id="setup-test">Set Up for Testing</h2> |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 81 | |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 82 | <p> |
| 83 | Testing app with the preview requires that you have a device or virtual device configured with |
| 84 | the preview version of the platform. If you have a compatible device, you can install the preview |
| 85 | platform for testing. Otherwise, you can configure a virtual device for testing. |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 86 | </p> |
| 87 | |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 88 | <h3 id="setup-device">Set up a Physical Device</h3> |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 89 | |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 90 | <p> |
| 91 | If you have a Nexus 5, Nexus 6, Nexus 9, or Nexus Player, you can install a preview |
| 92 | system image on these devices for testing your app. |
| 93 | You can set up virtual device with the preview version of the platform from within Android Studio |
| 94 | using the Android Virtual Device Manager tool. |
| 95 | </p> |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 96 | |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 97 | <p class="caution"> |
| 98 | <strong>Important:</strong> Installing a preview image on a device <em>removes all data from |
| 99 | it</em>, so you should backup any data before installing a preview image. |
| 100 | </p> |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 101 | |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 102 | <h3 id="setupAVD">Set up a Virtual Device</h3> |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 103 | |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 104 | <p> |
| 105 | You can set up virtual device with the preview version of the platform from within Android Studio |
| 106 | using the Android Virtual Device Manager tool. |
| 107 | </p> |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 108 | |
| 109 | <p>To create an AVD with the AVD Manager:</p> |
| 110 | |
| 111 | <ol> |
| 112 | <li>Install the M Preview SDK in your development environment, as described |
| 113 | in <a href="{@docRoot}preview/setup-sdk.html">Setting Up the Preview |
| 114 | SDK.</a></li> |
| 115 | <li>Follow the steps in |
| 116 | <a href="{@docRoot}tools/devices/managing-avds.html">Managing AVDs with AVD |
| 117 | Manager</a>. Use the following settings: |
| 118 | <ul> |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 119 | <li><strong>Device:</strong> Nexus 5, Nexus 6, Nexus 9, or Nexus Player</li> |
| 120 | <li><strong>Target:</strong> |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 121 | Android M (Preview) - API Level M</li> |
| 122 | </ul> |
Joe Fernandez | 306f1ce | 2015-05-01 12:51:21 -0700 | [diff] [blame] | 123 | </li> |
| 124 | </ol> |
| 125 | |
Joe Fernandez | 23fcc39 | 2015-05-19 12:27:07 -0700 | [diff] [blame^] | 126 | <p> |
| 127 | For more information about creating virtual devices for testing, see <a href= |
| 128 | "{@docRoot}tools/devices/index.html">Managing Virtual Devices</a>. |
| 129 | </p> |