page.title=Running Your App
parent.title=Building Your First App
parent.link=index.html

trainingnavtop=true
page.tags=emulator

@jd:body


<!-- This is the training bar -->
<div id="tb-wrapper">
<div id="tb">

<h2>This lesson teaches you to</h2>

<ol>
  <li><a href="#RealDevice">Run on a Real Device</a></li>
  <li><a href="#Emulator">Run on an Emulator</a></li>
</ol>

<h2>You should also read</h2>

<ul>
  <li><a href="{@docRoot}tools/device.html">Using Hardware Devices</a></li>
  <li><a href="{@docRoot}tools/devices/managing-avds.html">Managing AVDs with AVD Manager</a></li>
</ul>


</div>
</div>


<p>In the <a href="creating-project.html">previous lesson</a>, you created an
Android project that displays "Hello World." You can now run the app on a real
device or on an emulator. If you don't have a real device available, skip to
<a href="#Emulator">Run on an Emulator</a>.</p>


<h2 id="RealDevice">Run on a Real Device</h2>

<p>Set up your device as follows:</p>

<ol>
  <li>Connect your device to your development machine with a USB cable.
    If you're developing on Windows, you might need to install the appropriate USB driver for your
    device. For help installing drivers, see the <a href="{@docRoot}studio/run/oem-usb.html">OEM
    USB Drivers</a> document.</li>
  <li>Enable <strong>USB debugging</strong> on your device by going to
    <strong>Settings > Developer options</strong>.
        <p class="note"><strong>Note:</strong> On Android 4.2 and newer, <strong>Developer
        options</strong> is hidden by default. To make it available, go
        to <strong>Settings > About phone</strong> and tap <strong>Build number</strong>
        seven times. Return to the previous screen to find <strong>Developer options</strong>.</p>
  </li>
</ol>

<p>Run the app from Android Studio as follows:</p>

<ol>
  <li>In Android Studio, select your project and click
    <strong>Run</strong> <img src="{@docRoot}images/tools/as-run.png"
    style="vertical-align:baseline;margin:0; max-height:1em" />
    from the toolbar.</li>
  <li>In the <strong>Select Deployment Target</strong> window,
    select your device, and click <strong>OK</strong>.</li>
</ol>
<p>Android Studio installs the app on your connected device and starts it.</p>


<h2 id="Emulator">Run on an Emulator</h2>

<p>Before you run your app on an emulator, you need to create an
  <a href="{@docRoot}tools/devices/index.html">Android Virtual Device</a> (AVD)
  definition. An AVD definition defines the characteristics of an Android phone,
  tablet, Android Wear, or Android TV device that you want to simulate in the
  Android Emulator.</p>

<p>Create an AVD Definition as follows:</p>
<ol>
  <li>Launch the Android Virtual Device Manager by selecting
    <strong>Tools &gt; Android &gt; AVD Manager</strong>, or by clicking
    the AVD Manager icon <img src="{@docRoot}images/tools/avd-manager-studio.png"
    style="vertical-align:bottom;margin:0;height:19px"> in the toolbar.</li>
  <li>In the <b>Your Virtual Devices</b> screen, click <strong>Create Virtual Device</strong>.</li>
  <li>In the <b>Select Hardware</b> screen, select a phone device, such as Nexus 6,
    and then click <strong>Next</strong>.
  </li>
  <li>In the <b>System Image</b> screen, choose the desired system image for the AVD and
    click <strong>Next</strong>.
    <p>If you don't have a particular system image installed,
    you can get it by clicking the <b>download</b> link.</p>
  </li>
  <li>Verify the configuration settings (for your first AVD, leave all the
    settings as they are), and then click <strong>Finish</strong>.
  </li>
</ol>

<p>For more information about using AVDs, see
<a href="{@docRoot}studio/run/managing-avds.html">Create and Manage Virtual Devices</a>.</p>

<p>Run the app from Android Studio as follows:</p>
<ol>
  <li>In <strong>Android Studio</strong>, select your project and click
    <strong>Run</strong> <img src="{@docRoot}images/tools/as-run.png"
    style="vertical-align:baseline;margin:0; max-height:1em" />
    from the toolbar.</li>
  <li>In the <strong>Select Deployment Target</strong> window,
    select your emulator and click <strong>OK</strong>.</li>
</ol>
<p>It can take a few minutes for the emulator to start. You may have to unlock the screen.
When you do, <em>My First App</em> appears on the emulator screen.</p>


<p>That's how you build and run your Android app on the emulator!
To start developing, continue to the <a href="building-ui.html">next
lesson</a>.</p>