Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f895942d authored by smain@google.com's avatar smain@google.com Committed by Android (Google) Code Review
Browse files

Merge "docs: setup-virtual-device"

parents 690047f5 c56cd34d
Loading
Loading
Loading
Loading
+4.39 KiB
Loading image diff...
−546 B
Loading image diff...
+35 −35
Original line number Original line Diff line number Diff line
@@ -160,7 +160,7 @@ href="{@docRoot}tools/devices/index.html">Managing Virtual Devices</a>.</p>


<p>During development and testing of your application, you install and run your
<p>During development and testing of your application, you install and run your
application in the Android emulator. You can launch the emulator as a standalone
application in the Android emulator. You can launch the emulator as a standalone
application from a command line, or you can run it from within your Eclipse
application from a command line, or you can run it from within your Android Studio
development environment. In either case, you specify the AVD configuration to
development environment. In either case, you specify the AVD configuration to
load and any startup options you want to use, as described in this document.
load and any startup options you want to use, as described in this document.
</p>
</p>
@@ -188,13 +188,13 @@ window. For more information about command line options for the emulator, see th
instances of the emulator concurrently, each with its own AVD configuration and
instances of the emulator concurrently, each with its own AVD configuration and
storage area for user data, SD card, and so on.</p>
storage area for user data, SD card, and so on.</p>


<p>If you are working in Eclipse, the ADT plugin for Eclipse installs your
<p>When you run your app from Android Studio, it installs and launches the
application and starts the emulator automatically, when you run or debug
app on your connected device or emulator (launching the emulator, if necessary).
the application. You can specify emulator startup options in the Run/Debug
You can specify emulator startup options in the Run/Debug
dialog, in the Target tab. When the emulator is running, you can issue
dialog, in the Target tab. When the emulator is running, you can issue
console commands as described later in this document.</p>
console commands as described later in this document.</p>


<p>If you are not working in Eclipse, see <a href="#apps">Installing Applications
<p>If you are not working in Android Studio, see <a href="#apps">Installing Applications
on the Emulator</a> for information about how to install your application.</p>
on the Emulator</a> for information about how to install your application.</p>


<p>To stop an emulator instance, just close the emulator's window.</p>
<p>To stop an emulator instance, just close the emulator's window.</p>
@@ -206,7 +206,7 @@ reference.</p>


<h2 id="apps">Installing Applications on the Emulator</h2>
<h2 id="apps">Installing Applications on the Emulator</h2>


<p>If you don't have access to Eclipse or the ADT Plugin, you can install your application on the
<p>If you don't have access to Android Studio, you can install your application on the
emulator using the <a href="{@docRoot}tools/help/adb.html#move">adb</a> utility. Before
emulator using the <a href="{@docRoot}tools/help/adb.html#move">adb</a> utility. Before
installing the application, you need to build and package it into an <code>.apk</code> as described
installing the application, you need to build and package it into an <code>.apk</code> as described
in <a href="{@docRoot}tools/building/index.html">Building and
in <a href="{@docRoot}tools/building/index.html">Building and
@@ -287,16 +287,16 @@ option:
Android 4.0.3 (API Level 15, revision 3) or higher system image target. Graphics acceleration is not
Android 4.0.3 (API Level 15, revision 3) or higher system image target. Graphics acceleration is not
available for earlier system images.</p>
available for earlier system images.</p>
  </li>
  </li>
  <li>If you are running the emulator from Eclipse, run your Android application using an AVD with
  <li>If you are running the emulator from Android Studio, run your Android application using an AVD
the {@code -gpu on} option enabled:
with the {@code -gpu on} option enabled:
    <ol>
    <ol>
      <li>In Eclipse, click your Android project folder and then select <strong>Run > Run
      <li>In Android Studio, click your Android application module folder and then select
Configurations...</strong></li>
      <strong>Run > Edit Configurations...</strong></li>
      <li>In the left panel of the <strong>Run Configurations</strong> dialog, select your Android
      <li>In the left panel of the <strong>Run/Debug Configurations</strong> dialog, select your Android
project run configuration or create a new configuration.</li>
      run configuration or create a new configuration.</li>
      <li>Click the <strong>Target</strong> tab.</li>
      <li>Under the <strong>Device Target</strong> options,
      <li>Select the AVD you created in the previous procedure.</li>
      select the AVD you created in the previous procedure.</li>
      <li>In the <strong>Additional Emulator Command Line Options</strong> field, enter:<br>
      <li>In the <strong>Additional Command Line Options</strong> field, enter:<br>
        {@code -gpu on}</li>
        {@code -gpu on}</li>
      <li>Run your Android project using this run configuration.</li>
      <li>Run your Android project using this run configuration.</li>
    </ol>
    </ol>
@@ -414,15 +414,15 @@ SERVICE_NAME: intelhaxm
    <p class="note"><strong>Note:</strong> You must provide an x86-based AVD configuration
    <p class="note"><strong>Note:</strong> You must provide an x86-based AVD configuration
name, otherwise VM acceleration will not be enabled.</p>
name, otherwise VM acceleration will not be enabled.</p>
  </li>
  </li>
  <li>If you are running the emulator from Eclipse, run your Android application with an x86-based
  <li>If you are running the emulator from Android Studio, run your Android application with an x86-based
AVD:
AVD:
    <ol>
    <ol>
      <li>In Eclipse, click your Android project folder and then select <strong>Run > Run
      <li>In Android Studio, click your Android project folder and then select <strong>Run > Edit
Configurations...</strong></li>
Configurations...</strong></li>
      <li>In the left panel of the <strong>Run Configurations</strong> dialog, select your Android
      <li>In the left panel of the <strong>Run/Debug Configurations</strong> dialog, select your Android
project run configuration or create a new configuration.</li>
run configuration or create a new configuration.</li>
      <li>Click the <strong>Target</strong> tab.</li>
      <li>Under the <strong>Device Target</strong> options, select the x86-based AVD you created
      <li>Select the x86-based AVD you created previously.</li>
previously.</li>
      <li>Run your Android project using this run configuration.</li>
      <li>Run your Android project using this run configuration.</li>
    </ol>
    </ol>
  </li>
  </li>
@@ -467,15 +467,15 @@ opening a terminal window and running the following command:
    <p class="note"><strong>Note:</strong> You must provide an x86-based AVD configuration
    <p class="note"><strong>Note:</strong> You must provide an x86-based AVD configuration
name, otherwise VM acceleration will not be enabled.</p>
name, otherwise VM acceleration will not be enabled.</p>
  </li>
  </li>
  <li>If you are running the emulator from Eclipse, run your Android application with an x86-based
  <li>If you are running the emulator from Andriod Studio, run your Android application with an x86-based
AVD:
AVD:
    <ol>
    <ol>
      <li>In Eclipse, click your Android project folder and then select <strong>Run > Run
      <li>In Android Studio, click your Android module folder and then select <strong>Run > Edit
Configurations...</strong></li>
Configurations...</strong></li>
      <li>In the left panel of the <strong>Run Configurations</strong> dialog, select your Android
      <li>In the left panel of the <strong>Run/Debug Configurations</strong> dialog, select your Android
project run configuration or create a new configuration.</li>
run configuration or create a new configuration.</li>
      <li>Click the <strong>Target</strong> tab.</li>
      <li>Under the <strong>Device Target</strong> options,
      <li>Select the x86-based AVD you created previously.</li>
      select the x86-based AVD you created previously.</li>
      <li>Run your Android project using this run configuration.</li>
      <li>Run your Android project using this run configuration.</li>
    </ol>
    </ol>
  </li>
  </li>
@@ -513,16 +513,16 @@ AVD and include the KVM options:
    <p class="note"><strong>Note:</strong> You must provide an x86-based AVD configuration
    <p class="note"><strong>Note:</strong> You must provide an x86-based AVD configuration
name, otherwise VM acceleration will not be enabled.</p>
name, otherwise VM acceleration will not be enabled.</p>
  </li>
  </li>
  <li>If you are running the emulator from Eclipse, run your Android application with an x86-based
  <li>If you are running the emulator from Android Studio, run your Android application with an x86-based
AVD and include the KVM options:
AVD and include the KVM options:
    <ol>
    <ol>
      <li>In Eclipse, click your Android project folder and then select <strong>Run > Run
      <li>In Android Studio, click your Android module folder and then select <strong>Run > Edit
Configurations...</strong></li>
Configurations...</strong></li>
      <li>In the left panel of the <strong>Run Configurations</strong> dialog, select your Android
      <li>In the left panel of the <strong>Run/Debug Configurations</strong> dialog, select your Android
project run configuration or create a new configuration.</li>
run configuration or create a new configuration.</li>
      <li>Click the <strong>Target</strong> tab.</li>
      <li>Under the <strong>Device Target</strong> options, select the x86-based AVD you created
      <li>Select the x86-based AVD you created previously.</li>
previously.</li>
      <li>In the <strong>Additional Emulator Command Line Options</strong> field, enter:
      <li>In the <strong>Additional Command Line Options</strong> field, enter:
        <pre>-qemu -m 512 -enable-kvm</pre>
        <pre>-qemu -m 512 -enable-kvm</pre>
      </li>
      </li>
      <li>Run your Android project using this run configuration.</li>
      <li>Run your Android project using this run configuration.</li>
@@ -721,7 +721,7 @@ in the AVD directory, or in a custom location (if you specified a path with the
  <td>Override using <code>-data &lt;filepath&gt;</code>, where <code>&lt;filepath&gt;</code> is the
  <td>Override using <code>-data &lt;filepath&gt;</code>, where <code>&lt;filepath&gt;</code> is the
path the image, relative to the current working directory. If you supply a filename only,
path the image, relative to the current working directory. If you supply a filename only,
the emulator looks for the file in the current working directory. If the file at <code>&lt;filepath&gt;</code> does
the emulator looks for the file in the current working directory. If the file at <code>&lt;filepath&gt;</code> does
not exist, the emulator creates an image from the default userdata.img, stores it under the name you
not exist, the emulator creates an image from the default <code>userdata.img</code>, stores it under the name you
specified, and persists user data to it at shutdown. </td>
specified, and persists user data to it at shutdown. </td>
</tr>
</tr>


+102 −96
Original line number Original line Diff line number Diff line
@@ -10,100 +10,110 @@ parent.link=index.html
      <ol>
      <ol>
        <li><a href="#createavd">Creating an AVD</a>
        <li><a href="#createavd">Creating an AVD</a>
          <ol>
          <ol>
            <li><a href="#CreateDefinition">Creating a device definition</a></li>
            <li><a href="#hardwareopts">Hardware options</a></li>
            <li><a href="#hardwareopts">Hardware options</a></li>
          </ol>
          </ol>
        </li>
        </li>
        <li><a href="#skins">Creating Emulator Skins</a></li>
      </ol>
      </ol>
    </div>
    </div>
  </div>
  </div>


  <p>The AVD Manager is an easy to use user interface to manage your AVD (Android Virtual Device)
  <p>The AVD Manager is a tool you can use
  configurations. An AVD is a device configuration for the Android emulator that allows you to
  to create and manage Android virtual devices (AVDs), which define device configurations
  model different configurations of Android-powered devices. When you start the AVD Manager in Android
  for the <a href="{@docRoot}tools/devices/emulator.html"
  Studio or navigate to your SDK's {@code tools/} directory and execute
  >Android Emulator</a>.</p>
  <code>android avd</code>, you will see the AVD Manager main screen with your current virtual
  devices. You can right-click an existing AVD to perform actions on the AVD, such as delete,
  duplicate, wipe data, show on disk, and display details. </p>


   <img src="{@docRoot}images/studio-avdmgr-firstscreen.png" alt="">
<p>To launch the AVD Manager:</p>
   <p class="img-caption"><strong>Figure 1.</strong> AVD Manager.</p>
<ul>
  <li>In Android Studio, select <strong>Tools &gt; Android &gt; AVD Manager</strong>, or click
  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>Or, use the command line to navigate to your SDK's <code>tools/</code> directory and execute:
  <pre class="no-prettyprint classic">$ android avd</pre>
  </li>
</ul>


  <h2 id="createavd">Creating an AVD</h2>
  <p>The AVD Manager main screen shows your current virtual devices, as shown in figure 1.</p>


  <p>You can create as many AVDs as you would like to test on. It is recommended that you test your
  applications on all API levels higher than the target API level for your application.</p>


  <p>To create an AVD:</p>
   <img src="{@docRoot}images/studio-avdmgr-firstscreen.png" alt="">
   <p class="img-caption"><strong>Figure 1.</strong> The AVD Manager main screen shows your current
   virtual devices.</p>


  <ol>
    <li>Start the AVD Manager:


      <ul>
<p class="note"><strong>Note:</strong> If you launch the AVD Manager from the command line, the UI
        <li>In Android Studio: select <strong>Tools &gt; Android &gt; AVD Manager</strong>, or click
is different than how it appears in Android Studio, as documented here. Most of the same
        the AVD Manager icon <img src="{@docRoot}images/ui/studio-avdmgr-icon.png"style="vertical-align:bottom;margin:0;height:19px"> in the Android Studio toolbar.</li>
functionality is available, but the command-line version of the AVD Manager
is currently not documented.</p>




        <li>In other IDEs: Navigate to your SDK's <code>tools/</code> directory and execute the
  <h2 id="createavd">Creating an AVD</h2>
        <code>android</code> tool with no arguments.</li>
      </ul>
    </li>


    <li><p>Click <strong>Create Virtual Device</strong> to create an AVD. The
  <p>You can create as many AVDs as you would like to use with the Android Emulator.
    <strong>Select Hardware</strong> dialog appears.</p>
  To effectively test your app, you should create an AVD that models each device type for which
  you have designed your app to support. For instance, you should create an AVD for each
  API level equal to and higher than the minimum version you've specified in your manifest
  <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html" style="white-space: nowrap;"
  >{@code &lt;uses-sdk>}</a> tag.</p>


      <img src="{@docRoot}images/studio-avdmgr-selecthdwr.png">
  <p>To create an AVD based on an existing device definition:</p>
      <p class="img-caption"><strong>Figure 2.</strong> Select Hardware window.</p>
    </li>


    <li><p>Select the device category and form factor. Click <strong>Edit Device</strong> to modify
  <ol>
    an existing AVD, or click <strong>New Hardware Profile</strong> to create a new hardware profile.
    <li>From the main screen (figure 1), click <strong>Create Virtual Device</strong>.</li>
    Click <strong>Next</strong> to continue. </p>
    <p>The hardware profile includes settings for screen size, camera, memory options,input type,
    and sensors. For a list of hardware features, see <a href="#hardwareopts">Hardware options</a>.</p>


      <img src="{@docRoot}images/studio-avdmgr-confighardwareprof.png" alt="">
    <li><p>In the Select Hardware window, select a device configuration, such as Nexus 6,
      <p class="img-caption"><strong>Figure 3.</strong> Configure Hardware window.</p>
    then click <strong>Next</strong>.</p>
    </li>


    <li>Select the desired system image.  Click <strong>Install Latest Version</strong> to download
      <img src="{@docRoot}images/studio-avdmgr-selecthdwr.png" alt="">
    a new system image. Click <strong>Next</strong> to continue.
      <p class="img-caption"><strong>Figure 2.</strong> The Select Hardware window.</p>
    </li>
    <li>Select the desired system version for the AVD and click <strong>Next</strong>.
    </li>
    </li>
    <li>Verify the configuration settings, then click <strong>Finish</strong>.
    <p>If necessary, click <strong>Show Advanced Settings</strong> to select a custom skin
      for the hardware profile and adjust other hardware settings.</p>
    </li>
  </ol>


    <li>Fill in the details for the AVD.
  <p>To launch the AVD in the Android Emulator, click the launch button
  <img src="{@docRoot}images/tools/as-avd-start.png"
  style="vertical-align:bottom;margin:0;height:19px">
   in the list of AVDs.</p>


      <p>Give it a name, device type, platform target, image size, orientation, and emulator
      performance. Click <strong>Show Advanced Settings</strong> to assign a custom skin to the
      hardware profile and other advanced settings for the device type.
      </p>


      <p class="note"><strong>Tip:</strong>Store custom skins in an easily accessible directory,
<h3 id="CreateDefinition">Creating a device definition</h3>
      such as <em>~/skins</em>. From information about custom skins, see

      <a href="#skins">Skins</a>. </p>
<p>In case the available device definitions do not match the device type you'd like to emulate,
you can create a custom device definition for your AVD:</p>
<ol>
  <li>From the main screen (figure 1), click <strong>Create Virtual Device</strong>.</li>
  <li>To begin you custom device by using an existing device profile as a template, select
  a device profile then click <strong>Clone Device</strong>.
  <p>Or, to start from scratch, click <strong>New Hardware Profile</strong>.</p>
  </li>
  <li>
<p>The following Configure Hardware Profile window (figure 3) allows you to specify various
configurations such as the screen size, memory options, input type, and sensors.</p>


      <img src="{@docRoot}images/studio-avdmgr-configavd.png" alt="">
    <p>When you're done configuring the device, click <strong>Finish</strong>.</p>
      <p class="img-caption"><strong>Figure 4.</strong> Configure AVD window.</p>


      <p class="note"><strong>Tip:</strong> Be sure to define a target for your AVD that satisfies
      <img src="{@docRoot}images/studio-avdmgr-confighardwareprof.png" alt="">
      your application's Build Target (the AVD platform target must have an API Level equal to or
      <p class="img-caption"><strong>Figure 3.</strong> The Configure Hardware window when
      greater than the API Level that your application compiles against).</p>
      creating a custom device configuration.</p>
    </li>
    </li>
  <li>Your custom device configuration is now available in the list of device definitions
  (shown after you click <strong>Create Virtual Device</strong>). To continue preparing an AVD
  with your custom device configuration, select the new configuration and follow the instructions
  above to create an AVD with an existing device definition (and select your new definition).</li>


    <li>Click <strong>Finish</strong>.</li>
  </ol>
  </ol>


  <p>Your AVD is now ready and you can either close the AVD Manager, create more AVDs, or
  manage an emulator with the AVD by clicking an icon in the <strong>Actions</strong> column:
  </p>

  <ul>
    <li>Start an AVD <img src="{@docRoot}images/tools/studio-avdmgr-action-icon.png" alt=""></li>
    <li>Edit an AVD <img src="{@docRoot}images/tools/studio-avdmgr-actions-edit-icon.png" alt=""></li>
    <li>Perform management actions <img src="{@docRoot}images/tools/studio-avdmgr-actions-dropdown-icon.png" alt=""></li>
  </ul>




<h3 id="hardwareopts">Hardware options</h3>
<h3 id="hardwareopts">Hardware options</h3>

<p>If you are creating a new AVD, you can specify the following hardware options for the AVD
<p>If you are creating a new AVD, you can specify the following hardware options for the AVD
to emulate:</p>
to emulate:</p>


@@ -264,28 +274,31 @@ to emulate:</p>
  </table>
  </table>




<h3 id="skins">Using Custom Emulator Skins</h3>
<h2 id="skins">Creating Emulator Skins</h2>
<p>A custom Android emulator skin is a collection of files that enable you to customize the visual

and control elements of an emulator display. Custom emulator skins enable you to define variations
<p>An Android emulator skin is a collection of files that define the visual and control elements of
of emulation properties, such as the use of a trackball or touchscreen, to match your device
an emulator display. If the skin definitions available in the AVD settings don't meet your needs,
customizations. Each custom emulator skin contains:</p>
you can create your own custom skin definition, then apply it to your AVD from the
advanced settings on the Verify Configuration screen.</p>

<p>Each emulator skin contains:</p>
   <ul>
   <ul>
      <li>A <code>hardware.ini file</code> for initialization settings</li>
      <li>A <code>hardware.ini</code> file</li>
      <li>Layout files for supported orientations (landscape, portrait) and physical configuration</li>
      <li>Layout files for supported orientations (landscape, portrait) and physical configuration</li>
      <li>Image files for display elements, such as background, keys and buttons</li>
      <li>Image files for display elements, such as background, keys and buttons</li>
    </ul>
    </ul>
<p>To create and use a custom skin:</p>
<p>To create and use a custom skin:</p>
 <ol>
 <ol>
      <li>Create a skin folder in an easily accessible location, such as  <em>~/skins</em>. </li>
    <li>Create a new directory where you will save your skin configuration files. </li>
      <li>Define the skin orientation and configuration settings in a file called <code>layout</code>
    <li>Define the visual appearance of the skin in a text file named
      in the skin folder.
    <code>layout</code>. This file defines many characteristics of the skin, such as the
<pre>
    size and image assets for specific buttons. For example:
<pre class="no-prettyprint">
parts {
parts {

    device {
    device {
        display {
        display {
            width   1080
            width   320
            height  1920
            height  480
            x       0
            x       0
            y       0
            y       0
        }
        }
@@ -306,25 +319,18 @@ parts {
    }
    }
    ...
    ...
}
}

</pre></li>
</pre></li>


      <li>Creates a <code>hardware.ini</code> file for the skin-specific properties that determine
  <li>Add the bitmap files of the device images in the same directory.</li>
      emulator specifications and behavior. For a complete list of emulator properties, see
  <li>Specify additional hardware-specific device configurations an <code>hardware.ini</code>
      <a href="{@docRoot}tools/devices/managing-avds-cmdline.html">Managing AVDs from the Command
  file for the device settings, such as <code>hw.keyboard</code> and
      Line</a>. For example:</li>
  <code>hw.lcd.density</code>.</li>
<pre>
  <li>Archive the files in the skin folder and select the archive file as a custom skin. </li>
# skin-specific hardware values
hw.lcd.density=213
vm.heapSize=48
hw.ramSize=1024
hw.keyboard.lid=no
hw.mainKeys=no
</pre>
      <li>Add the bitmap files of the device images to the skin folder. </li>
      <li>Archive the files in the skin folder. </li>
      <li>Create a new AVD and select the archive file as a custom skin. </li>
</ol>
</ol>


<p>You can now run the AVD with a custom skin for testing and viewing your app. </p>
<p>For more detailed information about creating emulator skins, see the
<a href="https://android.googlesource.com/platform/external/qemu.git/+/master/docs/ANDROID-SKIN-FILES.TXT"
>Android Emulator Skin File Specification</a> in the tools source code.</p>


+1 −1

File changed.

Contains only whitespace changes.