2016-03-03 14:53:16 -08:00
|
|
|
page.title=Set Up the SDK
|
|
|
|
meta.keywords="preview", "android"
|
|
|
|
page.tags="preview", "developer preview"
|
|
|
|
page.image=images/cards/card-n-sdk_2x.png
|
2016-02-06 18:24:32 -08:00
|
|
|
|
|
|
|
@jd:body
|
|
|
|
|
|
|
|
|
|
|
|
<div id="qv-wrapper">
|
|
|
|
<div id="qv">
|
|
|
|
<h2>In this document</h2>
|
|
|
|
<ol>
|
2016-03-02 21:30:31 -08:00
|
|
|
<li><a href="#get-as13">Get Android Studio 2.1</a></li>
|
|
|
|
<li><a href="#get-sdk">Get the Preview SDK</a></li>
|
|
|
|
<li><a href="#java8">Get the Java 8 JDK</a></li>
|
2016-02-06 18:24:32 -08:00
|
|
|
<li><a href="#create-update">Create or Update a Project</a></li>
|
|
|
|
<li><a href="#setup-test">Set Up for Testing</a></li>
|
|
|
|
</ol>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2016-03-02 21:30:31 -08:00
|
|
|
<p>
|
|
|
|
You must have a development enviroment to make use of the Android N Developer
|
|
|
|
Preview. This document describes how to setup and configure a development
|
|
|
|
environment so you can use and test the Preview SDK.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
This document assumes that you are familiar with Android app development,
|
|
|
|
such as using the Android SDK Manager and creating projects. If you are new
|
|
|
|
to Android, see
|
|
|
|
<a href="{@docRoot}training/basics/firstapp/index.html">Building Your First
|
|
|
|
App</a> training lesson first.
|
|
|
|
</p>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
|
|
|
|
2016-03-02 21:30:31 -08:00
|
|
|
<h2 id="get-as13">Get Android Studio 2.1</h2>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
|
|
|
<p>
|
2016-03-02 21:30:31 -08:00
|
|
|
The Developer Preview is best used with Android Studio 2.1, which is also in
|
|
|
|
preview status. If you have an existing version of Android Studio you are
|
|
|
|
using for development, you should install a separate instance of Android
|
|
|
|
Studio for use with the Preview. This section describes how to install
|
|
|
|
an instance of Android Studio and update to version 2.1.
|
2016-02-06 18:24:32 -08:00
|
|
|
</p>
|
|
|
|
|
2016-03-02 21:30:31 -08:00
|
|
|
<p class="caution">
|
|
|
|
<strong>Caution:</strong> The canary preview of Android Studio 2.1 is still
|
|
|
|
in active development. If you are using your primary development machine to
|
|
|
|
test the developer preview, you should create a second installation of
|
|
|
|
Android Studio to use for testing the Developer Preview.
|
|
|
|
</p>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
2016-03-02 21:30:31 -08:00
|
|
|
<p>To install Android Studio and update to version 2.1:</p>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
|
|
|
<ol>
|
2016-03-02 21:30:31 -08:00
|
|
|
<li>Download, install, and launch the current version of
|
|
|
|
<a href="{@docRoot}tools/studio/index.html">Android Studio</a>.
|
2016-02-06 18:24:32 -08:00
|
|
|
</li>
|
|
|
|
|
2016-03-02 21:30:31 -08:00
|
|
|
<li>In Android Studio, open the <em>Settings</em> dialog and in the left
|
|
|
|
panel, choose <strong>Appearance & Behavior > System Settings >
|
|
|
|
Updates</strong>.
|
|
|
|
<ul>
|
|
|
|
<li>On Windows and Linux, open <em>Settings</em> by choosing
|
|
|
|
<strong>File > Settings</strong>.
|
|
|
|
</li>
|
|
|
|
<li>On Mac OS, open <em>Settings</em> by choosing
|
|
|
|
<strong>Android Studio > Preferences</strong>.
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
2016-03-02 21:30:31 -08:00
|
|
|
<li>On the <em>Updates</em> panel, make sure the <strong>Automatically
|
|
|
|
check updates for</strong> option is selected and choose the
|
|
|
|
<strong>Canary Channel</strong> option.
|
2016-02-06 18:24:32 -08:00
|
|
|
</li>
|
|
|
|
|
2016-03-02 21:30:31 -08:00
|
|
|
<li>On the <em>Updates</em> panel, click <strong>Check Now</strong>
|
|
|
|
to check for the latest canary build. Allow the software to download
|
|
|
|
and install the canary version when prompted.
|
2016-02-06 18:24:32 -08:00
|
|
|
</li>
|
2016-03-02 21:30:31 -08:00
|
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
|
|
<h2 id="java8">Get the Java 8 JDK</h2>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
You must use the Java 8 Development Kit with the N Developer Preview. If you
|
|
|
|
do not have this version of the JDK installed, download and install it before
|
|
|
|
working with the Preview SDK.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<p>To set the JDK version in Android Studio:</p>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
<li>Make sure you have installed the Java 8 JDK, and make a note of its
|
|
|
|
directory location on your development computer.</li>
|
|
|
|
<li>With a development project open in Android Studio, open the
|
|
|
|
<em>Project Structure</em> dialog by choosing <strong>File >
|
|
|
|
Project Structure</strong>.
|
|
|
|
</li>
|
|
|
|
<li>In the left panel of the dialog, click <strong>SDK Location</strong>.
|
|
|
|
</li>
|
|
|
|
<li>In the <strong>JDK Location</strong> field, enter the location of the
|
|
|
|
Java 8 JDK, and click <strong>OK</strong>.
|
|
|
|
</li>
|
|
|
|
</ul>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
2016-03-02 21:30:31 -08:00
|
|
|
|
|
|
|
<h2 id="get-sdk">Get the Preview SDK</h2>
|
|
|
|
|
|
|
|
<p>To add the Preview SDK to your Android Studio 2.1 development
|
|
|
|
environment:</p>
|
|
|
|
|
|
|
|
<ol>
|
|
|
|
<li>Launch Android Studio 2.1.
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>In Android Studio, open the <em>Settings</em> dialog and in the left
|
|
|
|
panel, choose <strong>Appearance & Behavior > System Settings >
|
|
|
|
Updates</strong>.
|
|
|
|
<ul>
|
|
|
|
<li>On Windows and Linux, open <em>Settings</em> by choosing
|
|
|
|
<strong>File > Settings</strong>.
|
|
|
|
</li>
|
|
|
|
<li>On Mac OS, open <em>Settings</em> by choosing
|
|
|
|
<strong>Android Studio > Preferences</strong>.
|
|
|
|
</li>
|
|
|
|
</ul>
|
2016-02-06 18:24:32 -08:00
|
|
|
</li>
|
|
|
|
|
2016-03-02 21:30:31 -08:00
|
|
|
<li>On the <em>Updates</em> panel, make sure the <strong>Automatically
|
|
|
|
check updates for Android SDK</strong> option is selected and choose the
|
|
|
|
<strong>Preview Channel</strong> option.
|
2016-02-06 18:24:32 -08:00
|
|
|
</li>
|
|
|
|
|
2016-03-02 21:30:31 -08:00
|
|
|
<li>In the <em>Settings</em> dialog left panel, choose
|
|
|
|
<strong>Appearance & Behavior > System Settings >
|
|
|
|
Android SDK</strong>.
|
2016-02-06 18:24:32 -08:00
|
|
|
</li>
|
|
|
|
|
2016-03-02 21:30:31 -08:00
|
|
|
<li>Click the <strong>SDK Platforms</strong> button, and then select
|
|
|
|
<strong>Android N Preview</strong>.
|
2016-02-06 18:24:32 -08:00
|
|
|
</li>
|
|
|
|
|
2016-03-02 21:30:31 -08:00
|
|
|
<li>Click the <strong>SDK Tools</strong> button, and select the latest
|
|
|
|
Android <strong>SDK Tools</strong>, <strong>Platform-tools</strong>, and
|
|
|
|
<strong>Build-tools</strong> versions.
|
|
|
|
</li>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
2016-03-02 21:30:31 -08:00
|
|
|
<li>Click <strong>OK</strong> and then accept the licensing
|
|
|
|
agreements for the packages to be installed.
|
2016-02-06 18:24:32 -08:00
|
|
|
</li>
|
|
|
|
</ol>
|
2016-03-02 21:30:31 -08:00
|
|
|
|
|
|
|
<p>After completing these steps, the preview components are available in your
|
|
|
|
development environment. </p>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
|
|
|
|
|
|
|
<h2 id="create-update">Create or Update a Project</h2>
|
|
|
|
|
|
|
|
<p>
|
2016-03-02 21:30:31 -08:00
|
|
|
In order to use the preview APIs, you must create or update a development
|
|
|
|
project to use the preview components.
|
2016-02-06 18:24:32 -08:00
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
<h3 id="create">Create a new project</h3>
|
|
|
|
|
|
|
|
<p>
|
2016-03-02 21:30:31 -08:00
|
|
|
Use the Android Studio new project wizard to create a project. For detailed
|
|
|
|
information on how to create a project with this too, see
|
|
|
|
<a href="{@docRoot}sdk/installing/create-project.html">Creating a Project</a>.
|
2016-02-06 18:24:32 -08:00
|
|
|
</p>
|
|
|
|
|
2016-03-02 21:30:31 -08:00
|
|
|
<p>To create a new project using the Preview SDK:</p>
|
|
|
|
|
|
|
|
<ol>
|
|
|
|
<li>Start the New Project wizard and follow the steps until you reach the
|
|
|
|
<em>Target Android Devices</em> page.
|
|
|
|
</li>
|
|
|
|
<li>On this page, select <strong>Phone and Tablet</strong> option.</li>
|
|
|
|
<li>Under <strong>Phone and Tablet</strong> option, in the <strong>Minimum
|
|
|
|
SDK</strong> option list, select <strong>Android N Preview</strong>.</li>
|
|
|
|
</ol>
|
2016-02-06 18:24:32 -08:00
|
|
|
|
|
|
|
|
|
|
|
<h3 id="update">Update an existing project</h3>
|
|
|
|
|
|
|
|
<p>
|
2016-03-02 21:30:31 -08:00
|
|
|
For existing projects, you must modify the project configuration to use the
|
|
|
|
Preview APIs. In your development environment, open the
|
|
|
|
<code>build.gradle</code> file for your module and set these values as
|
|
|
|
follows:
|
2016-02-06 18:24:32 -08:00
|
|
|
</p>
|
|
|
|
|
2016-03-02 21:30:31 -08:00
|
|
|
<pre>
|
|
|
|
android {
|
|
|
|
compileSdkVersion <strong>'android-N'</strong>
|
|
|
|
...
|
|
|
|
|
|
|
|
defaultConfig {
|
|
|
|
...
|
|
|
|
minSdkVersion <strong>'N'</strong>
|
|
|
|
targetSdkVersion <strong>'N'</strong>
|
|
|
|
...
|
|
|
|
}
|
|
|
|
...
|
|
|
|
}</pre>
|
|
|
|
|
2016-02-06 18:24:32 -08:00
|
|
|
|
|
|
|
|
|
|
|
<h2 id="setup-test">Set Up for Testing</h2>
|
|
|
|
|
|
|
|
<p>
|
2016-03-02 21:30:31 -08:00
|
|
|
Testing an app with the preview requires that you have a device or virtual
|
|
|
|
device configured with the preview version of the platform. If you have a
|
|
|
|
compatible device, you can install the preview platform for testing.
|
|
|
|
Otherwise, you can configure a virtual device for testing.
|
2016-02-06 18:24:32 -08:00
|
|
|
</p>
|
|
|
|
|
|
|
|
<h3 id="setup-device">Set up a physical device</h3>
|
|
|
|
|
|
|
|
<p>
|
2016-03-02 21:30:31 -08:00
|
|
|
If you have a Nexus 5X, Nexus 6P, Nexus 9, or Nexus Player, you can install a
|
|
|
|
preview system image on these devices for testing your app. You can set up a
|
|
|
|
virtual device with the preview version of the platform from within Android
|
|
|
|
Studio using the Android Virtual Device Manager tool.
|
2016-02-06 18:24:32 -08:00
|
|
|
</p>
|
|
|
|
|
|
|
|
<p class="caution">
|
2016-03-02 21:30:31 -08:00
|
|
|
<strong>Important:</strong> Installing a preview image on a device
|
|
|
|
<em>removes all data from it</em>, so you should backup any data before
|
|
|
|
installing a preview image.
|
2016-02-06 18:24:32 -08:00
|
|
|
</p>
|
|
|
|
|
|
|
|
<h3 id="setupAVD">Set up a virtual device</h3>
|
|
|
|
|
|
|
|
<p>
|
2016-03-02 21:30:31 -08:00
|
|
|
You can set up virtual device with the preview version of the platform from
|
|
|
|
within Android Studio using the Android Virtual Device Manager tool.
|
2016-02-06 18:24:32 -08:00
|
|
|
</p>
|
|
|
|
|
|
|
|
<p>To create an AVD with the AVD Manager:</p>
|
|
|
|
|
|
|
|
<ol>
|
|
|
|
<li>Install the Preview SDK in your development environment, as described
|
2016-03-02 21:30:31 -08:00
|
|
|
in <a href="{@docRoot}preview/setup-sdk.html">Setting Up the Preview
|
|
|
|
SDK.</a></li>
|
2016-02-06 18:24:32 -08:00
|
|
|
<li>Follow the steps in
|
2016-03-02 21:30:31 -08:00
|
|
|
<a href="{@docRoot}tools/devices/managing-avds.html">Managing AVDs with AVD
|
|
|
|
Manager</a>. Use the following settings:
|
2016-02-06 18:24:32 -08:00
|
|
|
<ul>
|
2016-03-02 21:30:31 -08:00
|
|
|
<li><strong>Device:</strong>
|
|
|
|
Nexus 5X, Nexus 6P, Nexus 9, or Android TV</li>
|
2016-02-06 18:24:32 -08:00
|
|
|
<li><strong>Target:</strong>
|
2016-03-02 21:30:31 -08:00
|
|
|
Android N (Preview) - API Level N</li>
|
|
|
|
<li><strong>ABI:</strong>
|
|
|
|
x86</li>
|
2016-02-06 18:24:32 -08:00
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
For more information about creating virtual devices for testing, see <a href=
|
|
|
|
"{@docRoot}tools/devices/index.html">Managing Virtual Devices</a>.
|
|
|
|
</p>
|