blob: b31b1047be24072746c8d7445d16cafcdd8f02aa [file] [log] [blame]
Dirk Dougherty74709452015-05-15 00:51:24 -07001page.title=Set Up the Preview SDK
2page.image=images/cards/card-set-up_16-9_2x.png
Joe Fernandez23fcc392015-05-19 12:27:07 -07003
Joe Fernandez306f1ce2015-05-01 12:51:21 -07004@jd:body
5
6
Joe Fernandez23fcc392015-05-19 12:27:07 -07007<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 Fernandez306f1ce2015-05-01 12:51:21 -070017
18<p>The Preview SDK is available from the Android SDK Manager.
19This document assumes that you are familiar with Android app development, such
Joe Fernandez23fcc392015-05-19 12:27:07 -070020as using the Android SDK Manager and creating projects. If you are new to
Joe Fernandez306f1ce2015-05-01 12:51:21 -070021Android, see <a href="{@docRoot}training/basics/firstapp/index.html">Building Your First
22App</a> training lesson first.</a></p>
23
Joe Fernandez23fcc392015-05-19 12:27:07 -070024<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 Fernandez306f1ce2015-05-01 12:51:21 -070027
28<ol>
29 <li>Start the <a href="{@docRoot}tools/help/sdk-manager.html">Android SDK Manager</a>.</li>
Joe Fernandez23fcc392015-05-19 12:27:07 -070030 <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 Fernandez306f1ce2015-05-01 12:51:21 -070034 <li>Accept the Licensing Agreement for all of the packages and click
Joe Fernandez23fcc392015-05-19 12:27:07 -070035 <strong>Install</strong>.</li>
Joe Fernandez306f1ce2015-05-01 12:51:21 -070036</ol>
37
Joe Fernandez23fcc392015-05-19 12:27:07 -070038<p>After completing these steps, the preview components are available in your development
39 environment. </p>
Joe Fernandez306f1ce2015-05-01 12:51:21 -070040
Joe Fernandez306f1ce2015-05-01 12:51:21 -070041
Joe Fernandez23fcc392015-05-19 12:27:07 -070042<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 Fernandez306f1ce2015-05-01 12:51:21 -070057</p>
58
59<ul>
Joe Fernandez23fcc392015-05-19 12:27:07 -070060 <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 Fernandez306f1ce2015-05-01 12:51:21 -070062</ul>
63
Joe Fernandez23fcc392015-05-19 12:27:07 -070064
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 Fernandez306f1ce2015-05-01 12:51:21 -070071</p>
72
Joe Fernandez23fcc392015-05-19 12:27:07 -070073<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 Fernandez306f1ce2015-05-01 12:51:21 -070078
79
Joe Fernandez23fcc392015-05-19 12:27:07 -070080<h2 id="setup-test">Set Up for Testing</h2>
Joe Fernandez306f1ce2015-05-01 12:51:21 -070081
Joe Fernandez23fcc392015-05-19 12:27:07 -070082<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 Fernandez306f1ce2015-05-01 12:51:21 -070086</p>
87
Joe Fernandez23fcc392015-05-19 12:27:07 -070088<h3 id="setup-device">Set up a Physical Device</h3>
Joe Fernandez306f1ce2015-05-01 12:51:21 -070089
Joe Fernandez23fcc392015-05-19 12:27:07 -070090<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 Fernandez306f1ce2015-05-01 12:51:21 -070096
Joe Fernandez23fcc392015-05-19 12:27:07 -070097<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 Fernandez306f1ce2015-05-01 12:51:21 -0700101
Joe Fernandez23fcc392015-05-19 12:27:07 -0700102<h3 id="setupAVD">Set up a Virtual Device</h3>
Joe Fernandez306f1ce2015-05-01 12:51:21 -0700103
Joe Fernandez23fcc392015-05-19 12:27:07 -0700104<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 Fernandez306f1ce2015-05-01 12:51:21 -0700108
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 Fernandez23fcc392015-05-19 12:27:07 -0700119 <li><strong>Device:</strong> Nexus 5, Nexus 6, Nexus 9, or Nexus Player</li>
120 <li><strong>Target:</strong>
Joe Fernandez306f1ce2015-05-01 12:51:21 -0700121 Android M (Preview) - API Level M</li>
122 </ul>
Joe Fernandez306f1ce2015-05-01 12:51:21 -0700123 </li>
124</ol>
125
Joe Fernandez23fcc392015-05-19 12:27:07 -0700126<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>