Android Virtual Devices 更改创建目录.
- You need to create an AVD to run any app in the Android emulator
- Each AVD is a completely independent virtual device, with its own hardware options, system image, and da
- You create AVD configurations to model different device environments in the Android emulator.
In this document
- Creating an AVD
- Managing AVDs
- Command-line options
Android Virtual Devices (AVDs) are configurations of emulator options that let you better model an actual device.
Each AVD is made up of:
- A hardware pro
file. You can set options to define the hardware features of the virtual device. For example, you can define whether the device has a camera, whether it uses a physical QWERTY keyboard or a dialing pad, how much memory it has, and so on.
- A mapping to a system image. You can define what version of the Android platform. will run on the virtual device. You can choose a version of the standard Android platform. or the system image packaged with an SDK add-on.
- Other options. You can specify the emulator skin you want to use with the AVD, which lets you control the screen dimensions, appearance, and so on. You can also specify the emulated SD card to use with the AVD.
- A dedicated storage area on your development machine, in which is stored the device's user da
ta (installed applications, settings, and so on) and emulated SD card.
You can create as many AVDs as you need, based on the types of devices you want to model and the Android platforms and external libraries you want to run your application on.
In addition to the options in an AVD configuration, you can also specify emulator command-line options at launch or by using the emulator console to change behaviors or characteristics at run time. For a complete reference of emulator options, please see the Emulatordocumentation.
To create and manage AVDs, you use the android tool provided in the Android SDK. For more information about how to work with AVDs from inside your development environment, see Developing in Eclipse with ADT or Developing in Other IDEs, as appropriate for your environment.
Creating an AVD
The Android SDK does not include any preconfigured AVDs, so you need to create an AVD before you can run any application in the emulator (even the Hello World application).
To create an AVD, you use the android tool, a command-line utility available in the <CO
To create each AVD, you issue the command <CO
Here's the command-line usage for creating an AVD:
android create avd -n <name> -t <targetID> [-<option> <value>] ...
You can use any name you want for the AVD, but since you are likely to be creating multiple AVDs, you should choose a name that lets you recognize the general characteristics offered by the AVD.
As shown in the usage above, you must use the <CO
specify the system image to use, you refer to its target ID — an
integer — as assigned by the android tool. The target ID is not derived
from the system image name, version, or API Level, or other attribute,
so you need to have the android tool list the available system images
and the target ID of each, as described in the next section. You should
do this before you run the <CO
To generate a list of system image targets, use this command:
android list targets
The android tool scans the <CO
Available Android targets:id:1 Name: Android 1.1 Type: platform API level: 2 Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-Pid:2 Name: Android 1.5 Type: platform API level: 3 Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-Pid:3 Name: Google APIs Type: add-on Vendor: Google Inc. Description: Android + Google APIs Based on Android 1.5 (API level 3) Libraries: * com.google.android.maps (maps.jar) API for Google Maps Skins: HVGA (default), HVGA-L, QVGA-P, HVGA-P, QVGA-L
Selecting a target
Keep these points in mind when you are selecting a system image target for your AVD:
- The API Level of the target is imp
ortant, because your application will not be able to run on a system image whose API Level is less than that required by your application, as specified in the<CO de style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">minSdkVersion</CO de> attribute of the application's manifest file. For more information about the relationship between system API Level and application <CO de style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">minSdkVersion</CO de>, see Specifying Minimum System API Version.
- Creating at least on
e AVD that uses a target whose API Level is greater than that required by your application is strongly encouraged, because it allows you to test the forward-compatibility of your application. Forward-compatibility testing ensures that, when users who have downloaded your application receive a system update, your application will continue to function normally.
- If your application declares a <CO
de style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">uses-library</CO de> element in its manifest file, the application can on ly run on a system image in which that external library is present. If you want your application to run on the AVD you are creating, check the application's <CO de style="color: rgb(0, 112, 0); font-family: monospace; line-height: 1em; ">uses-library</CO de> element and select a system image target that includes that library.
Creating the AVD
When you've selected the target you want to use and made a note of its ID, use the <CO
android create avd -n my_android1.5 -t 2
the target you selected was a standard Android system image ("Type:
platform"), the android tool next asks you whether you want to create a
custom hardware pro
Android 1.5 is a basic Android platform.Do you wish to create a custom hardware pro
If you want to set custom hardware emulation options for the AVD, enter "yes" and set values as needed. If you want to use the default hardware emulation options for the AVD, just press the return key (the default is "no"). The android tool creates the AVD with name and system image mapping you requested, with the options you specified.
If you are creating an AVD whose target is an SDK add-on, the android tool does not allow you to set hardware emulation options. It assumes that the provider of the add-on has set emulation options appropriately for the device that the add-on is modeling, and so prevents you from resetting the options.
For a list of options you can use in the <CO
Setting hardware emulation options
When are creating a new AVD that uses a standard Android system image ("Type: platform"), the android tool lets you set hardware emulation options for virtual device. The table below lists the options available and the default values, as well as the names of properties that store the emulated hardware options in the AVD's configuration file (the config.ini file in the AVD's local directory).
|Device ram size||The amount of physical RAM on the device, in megabytes. Default value is "96".||hw.ramSize|
|Touch-screen support||Whether there is a touch screen or not on the device. Default value is "yes".||hw.touchScreen|
|Trackball support||Whether there is a trackball on the device. Default value is "yes".||hw.trackBall|
|Keyboard support||Whether the device has a QWERTY keyboard. Default value is "yes".||hw.keyboard|
|DPad support||Whether the device has DPad keys. Default value is "yes".||hw.dPad|
|GSM modem support||Whether there is a GSM modem in the device. Default value is "yes".||hw.gsmModem|
|Camera support||Whether the device has a camera. Default value is "no".||hw.camera|
|Maximum horizontal camera pixels||Default value is "640".||hw.camera.maxHorizontalPixels|
|Maximum vertical camera pixels||Default value is "480".||hw.camera.maxVerticalPixels|
|GPS support||Whether there is a GPS in the device. Default value is "yes".||hw.gps|
|Battery support||Whether the device can run on a battery. Default value is "yes".||hw.battery|
|Accelerometer||Whether there is an accelerometer in the device. Default value is "yes".||hw.accelerometer|
|Audio recording support||Whether the device can record audio. Default value is "yes".||hw.audioInput|
|Audio playback support||Whether the device can play audio. Default value is "yes".||hw.audioOutput|
|SD Card support||Whether the device supports insertion/removal of virtual SD Cards. Default value is "yes".||hw.sdCard|
|Cache partition support||Whether we use a /cache partition on the device. Default value is "yes".||disk.cachePartition|
|Cache partition size||Default value is "66MB".||disk.cachePartition.size|
Default location of the AVD files
you create an AVD, the android tool creates a dedicated directory for
it on your development computer. The directory contains the AVD
configuration file, the user da
The android tool also creates a <AVD name>.ini file for the AVD at the root of the .android/avd directory on your computer. The file specifies the location of the AVD directory and always remains at the root the .android directory.
By default, the android tool creates the AVD directory inside <CO
android create avd -n my_android1.5 -t 2 -p path/to/my/avd
If the .android directory is hosted on a network drive, we recommend using the <CO
The sections below provide more information about how to manage AVDs on
Moving an AVD
If you want to move or rename an AVD, you can do so using this command:
android move avd -n <name> [-<option> <value>] ...
The options for this command are listed in Command-line options for AVDs at the bottom of this page.
Updating an AVD
for any reason, the platform/add-on root folder has its name changed
(maybe because the user has installed an update of the platform/add-on)
then the AVD will not be able to load the system image that it is
mapped to. In this case, the <CO
The following Android Virtual Devices could not be loaded: Name: foo Path: <path>/.android/avd/foo.avd Error: Invalid value in image.sysdir. Run 'android update avd -n foo'
To fix this error, use the <CO
Deleting an AVD
You can use the android tool to delete an AVD. Here is the command usage:
android delete avd -n <name>
When you issue the command, the android tool looks for an AVD matching the specified name deletes the AVD's directory and files.
Command-line options for AVDs
The table below lists the command-line options you can use with the android tool.
|<CO||List all known AVDs, with name, path, target, and skin.|
|The name for the AVD.||Required|
|<CO||Target ID of the system image to use with the new AVD.||Required. To obtain a list of available targets, use <CO|
|The path to the SD card image to use with this AVD or the size of a new SD card image to create for this AVD.||Examples: <CO|
|<CO||Force creation of the AVD||By
default, if the name of the AVD being created matches that of an
existing AVD, the android tool will not create the new AVD or overwrite
the existing AVD. If you specify the <CO|
|<CO||Path to the location at which to create the directory for this AVD's files.|
|The skin to use for this AVD, identified by name or dimensions.||The android tool scans for a matching skin by name or dimension in the <CO|
|<CO||<CO||Delete the specified AVD.||Required|
|<CO||<CO||The name of the AVD to move.||Required|
|<CO||The path to the new location for the AVD.|
|<CO||Rename the AVD.|
- Android单元测试例（附源码） (fishy, 2010-3-03)
- 联通首款全互联网3G手机本月上市 支持WiFi (51testing, 2010-3-04)
- 苹果与谷歌化友为敌：Android手机惹的祸 (51testing, 2010-3-05)
- 360手机卫士Android版完成测试 将于近日公测 (51testing, 2010-3-09)
- 韩国要求谷歌手机游戏遵守法律否则将受罚 (51testing, 2010-3-12)
- 谷歌Nexus One手机入华在即 TD版引争论 (夜一, 2010-3-31)
- 美股评论：缺乏娱乐是黑莓的死穴 (夜一, 2010-4-02)
- Android上的Webkit的测试 (fishy, 2010-4-06)
- Android vnc server 安装 (liyun100, 2010-4-06)
- 中移动研究院院长黄晓庆：1年内Ophone技术即可超越iPhone (51testing, 2010-4-08)
- 访问量: 50430
- 日志数: 80
- 建立时间: 2008-02-14
- 更新时间: 2013-08-09