• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1page.title=Managing AVDs from the Command Line
2parent.title=Managing Virtual Devices
3parent.link=index.html
4@jd:body
5
6<div id="qv-wrapper">
7  <div id="qv">
8  <h2>In this document</h2>
9  <ol>
10    <li><a href="#listingtargets">Listing Targets</a></li>
11    <li><a href="#AVDCmdLine">Creating AVDs</a>
12      <ol>
13        <li><a href="#CustomDensity">Customize the device resolution or density</a></li>
14        <li><a href="#DefaultLocation">Default location of AVD files</a></li>
15        <li><a href="#hardwareopts">Setting hardware emulation options</a></li>
16      </ol>
17    </li>
18    <li><a href="#moving">Moving an AVD</a></li>
19    <li><a href="#updating">Updating an AVD</a></li>
20    <li><a href="#deleting">Deleting an AVD</a></li>
21  </ol>
22  <h2>See also</h2>
23  <ol>
24    <li><a href="{@docRoot}tools/building/building-cmdline.html">Building and Running
25from the Command Line</a></li>
26    <li><a href="{@docRoot}tools/devices/emulator.html">Using the Android
27Emulator</a></li>
28  </ol>
29  </div>
30</div>
31
32
33<p>The <code>android</code> tool lets you manage AVDs on the command line. For a complete reference
34of the command line options that you can use, see the reference for the
35<a href="{@docRoot}tools/help/android.html"><code>android</code></a> tool.</p>
36
37
38
39<h2 id="listingtargets">Listing Targets</h2>
40
41<p>To generate a list of system image targets, use this command: </p>
42
43<pre>android list targets</pre>
44
45<p>The <code>android</code> tool scans the <code>&lt;sdk&gt;/platforms/</code> and
46<code>&lt;sdk&gt;/add-ons/</code> directories looking for valid system images and
47then generates the list of targets. Here's an example of the command output:
48</p>
49
50<pre>Available Android targets:
51id: 1 or "android-3"
52     Name: Android 1.5
53     Type: Platform
54     API level: 3
55     Revision: 4
56     Skins: QVGA-L, HVGA-L, HVGA (default), HVGA-P, QVGA-P
57id: 2 or "android-4"
58     Name: Android 1.6
59     Type: Platform
60     API level: 4
61     Revision: 3
62     Skins: QVGA, HVGA (default), WVGA800, WVGA854
63id: 3 or "android-7"
64     Name: Android 2.1-update1
65     Type: Platform
66     API level: 7
67     Revision: 2
68     Skins: QVGA, WQVGA400, HVGA (default), WVGA854, WQVGA432, WVGA800
69id: 4 or "android-8"
70     Name: Android 2.2
71     Type: Platform
72     API level: 8
73     Revision: 2
74     Skins: WQVGA400, QVGA, WVGA854, HVGA (default), WVGA800, WQVGA432
75id: 5 or "android-9"
76     Name: Android 2.3
77     Type: Platform
78     API level: 9
79     Revision: 1
80     Skins: HVGA (default), WVGA800, WQVGA432, QVGA, WVGA854, WQVGA400
81</pre>
82
83
84
85<h2 id="AVDCmdLine">Creating AVDs</h2>
86
87<p>In addition to creating AVDs with the
88<a href="{@docRoot}tools/devices/managing-avds-cmdline.html">AVD Manager user interface</a>,
89you can also create them by passing in command line arguments to the <code>android</code> tool.
90</p>
91
92<p>Open a terminal window and change to
93the <code>&lt;sdk&gt;/tools/</code> directory, if needed.</p>
94
95<p>To create each AVD, you issue the command <code>android create avd</code>,
96with options that specify a name for the new AVD and the system image you want
97to run on the emulator when the AVD is invoked. You can specify other options on
98the command line also, such as the emulated SD card size, the emulator skin, or a custom
99location for the user data files.</p>
100
101<p>Here's the command-line usage for creating an AVD: </p>
102
103<pre>android create avd -n &lt;name&gt; -t &lt;targetID&gt; [-&lt;option&gt; &lt;value&gt;] ... </pre>
104
105<p>You can use any name you want for the AVD, but since you are likely to be
106creating multiple AVDs, you should choose a name that lets you recognize the
107general characteristics offered by the AVD. The target ID is an integer assigned by the
108<code>android</code> tool. The target ID is not derived from the system image name,
109version, or API Level, or other attribute, so you need to run the <code>android list targets</code>
110command to list the target ID of each system image. You should do this <em>before</em> you run
111the <code>android create avd</code> command. See the <a
112href="{@docRoot}tools/help/android.html">android</a>
113tool documentation for more information on the command line options.</p>
114
115
116<p>When you've selected the target you want to use and made a note of its ID,
117use the <code>android create avd</code> command to create the AVD, supplying the
118target ID as the <code>-t</code> argument. Here's an example that creates an
119AVD with name "my_android1.5" and target ID "2" (the standard Android 1.5
120system image in the list above): </p>
121
122<pre>android create avd -n my_android1.5 -t 2</pre>
123
124<p>If the target you selected was a standard Android system image ("Type:
125platform"), the <code>android</code> tool next asks you whether you want to
126create a custom hardware profile. </p>
127<pre>Android 1.5 is a basic Android platform.
128Do you wish to create a custom hardware profile [no]</pre>
129
130<p>If you want to set custom hardware emulation options for the AVD, enter
131"yes" and set values as needed. If you want to use the default hardware
132emulation options for the AVD, just press the return key (the default is "no").
133The <code>android</code> tool creates the AVD with name and system image mapping you
134requested, with the options you specified. For more information, see <a href="#hardwareopts">
135Setting Hardware Emulation Options</a>.
136
137<p class="note"><strong>Note:</strong> If you are creating an AVD whose target is an SDK add-on, the
138<code>android</code> tool does not allow you to set hardware emulation options.
139It assumes that the provider of the add-on has set emulation options
140appropriately for the device that the add-on is modeling, and so prevents you
141from resetting the options. </p>
142
143
144<h3 id="CustomDensity">Customize the device resolution or density</h3>
145
146<p>When testing your application, we recommend that you test your application in several different
147AVDs, using different screen configurations (different combinations of size and density). In
148addition, you should set up the AVDs to run at a physical size that closely matches an actual
149device.</p>
150
151<p>To set up your AVDs for a specific resolution or density, follow these steps:</p>
152
153<ol>
154  <li>Use the <code>create avd</code> command to create a new AVD, specifying
155the <code>--skin</code> option with a value that references either a default
156skin name (such as "WVGA800") or a custom skin resolution (such as 240x432).
157Here's an example:
158     <pre>android create avd -n &lt;name&gt; -t &lt;targetID&gt; --skin WVGA800</pre>
159  </li>
160  <li>To specify a custom density for the skin, answer "yes" when asked whether
161you want to create a custom hardware profile for the new AVD.</li>
162  <li>Continue through the various profile settings until the tool asks you to
163specify "Abstracted LCD density" (<em>hw.lcd.density</em>). Enter an appropriate
164value, such as "120" for a low-density screen, "160" for a medium density screen,
165or "240" for a high-density screen.</li>
166  <li>Set any other hardware options and complete the AVD creation.</li>
167</ol>
168
169<p>In the example above (WVGA medium density), the new AVD will emulate a 5.8"
170WVGA screen.</p>
171
172<p>As an alternative to adjusting the emulator skin configuration, you can use
173the emulator skin's default density and add the <code>-dpi-device</code> option
174to the <a href="{@docRoot}tools/help/emulator.html">emulator</a> command line when
175starting the AVD. For example:</p>
176
177<pre>emulator -avd WVGA800 -scale 96dpi -dpi-device 160</pre>
178
179
180
181<h3 id="DefaultLocation">Default location of AVD files</h3>
182
183<p>When you create an AVD, the <code>android</code> tool creates a dedicated directory for it
184on your development computer. The directory contains the AVD configuration file,
185the user data image and SD card image (if available), and any other files
186associated with the device. Note that the directory does not contain a system
187image &mdash; instead, the AVD configuration file contains a mapping to the
188system image, which it loads when the AVD is launched. </p>
189
190<p>The <code>android</code> tool also creates an <code>&lt;AVD_name&gt;.ini</code> file for the AVD at the
191root of the <code>.android/avd/</code> directory on your computer. The file specifies the
192location of the AVD directory and always remains at the root the .android
193directory.</p>
194
195<p>By default, the <code>android</code> tool creates the AVD directory inside
196<code>~/.android/avd/</code> (on Linux/Mac), <code>C:\Documents and
197Settings\&lt;user&gt;\.android\</code> on Windows XP, and
198<code>C:\Users\&lt;user&gt;\.android\</code> on Windows 7 and Vista.
199If you want to use a custom location for the AVD directory, you
200can do so by using the <code>-p &lt;path&gt;</code> option when
201you create the AVD: </p>
202
203<pre>android create avd -n my_android1.5 -t 2 -p path/to/my/avd</pre>
204
205<p>If the .android directory is hosted on a network drive, we recommend using
206the <code>-p</code> option to place the AVD directory in another location.
207The  AVD's .ini file remains in the .android directory on the network
208drive, regardless of the location of the AVD directory.
209
210
211<h3 id="hardwareopts">Setting hardware emulation options</h3>
212
213<p>When you are creating a new AVD that uses a standard Android system image ("Type:
214platform"), the <code>android</code> tool lets you set hardware emulation
215options for virtual device. The table below lists the options available and the
216default values, as well as the names of properties that store the emulated
217hardware options in the AVD's configuration file (the config.ini file in the
218AVD's local directory). </p>
219
220<p class="table-caption"><strong>Table 1.</strong> Available hardware profile options for AVDs and
221the default values </p>
222
223<table>
224<tr>
225<th>Characteristic</th>
226<th>Description</th>
227<th>Property</th>
228</tr>
229
230<tr>
231<td>Device ram size</td>
232<td>The amount of physical RAM on the device, in megabytes. Default value is "96".
233<td>hw.ramSize</td>
234</tr>
235
236<tr>
237<td>Touch-screen support</td>
238<td>Whether there is a touch screen or not on the device. Default value is "yes".</td>
239<td>hw.touchScreen
240
241<tr>
242<td>Trackball support </td>
243<td>Whether there is a trackball on the device. Default value is "yes".</td>
244<td>hw.trackBall</td>
245</tr>
246
247<tr>
248<td>Keyboard support</td>
249<td>Whether the device has a QWERTY keyboard. Default value is "yes".</td>
250<td>hw.keyboard</td>
251</tr>
252
253<tr>
254<td>DPad support</td>
255<td>Whether the device has DPad keys. Default value is "yes".</td>
256<td>hw.dPad</td>
257</tr>
258
259<tr>
260<td>GSM modem support</td>
261<td>Whether there is a GSM modem in the device. Default value is "yes".</td>
262<td>hw.gsmModem</td>
263</tr>
264
265<tr>
266<td>Camera support</td>
267<td>Whether the device has a camera. Default value is "no".</td>
268<td>hw.camera</td>
269</tr>
270
271<tr>
272<td>Maximum horizontal camera pixels</td>
273<td>Default value is "640".</td>
274<td>hw.camera.maxHorizontalPixels</td>
275</tr>
276
277<tr>
278<td>Maximum vertical camera pixels</td>
279<td>Default value is "480".</td>
280<td>hw.camera.maxVerticalPixels</td>
281</tr>
282
283<tr>
284<td>GPS support</td>
285<td>Whether there is a GPS in the device. Default value is "yes".</td>
286<td>hw.gps</td>
287</tr>
288
289<tr>
290<td>Battery support</td>
291<td>Whether the device can run on a battery. Default value is "yes".</td>
292<td>hw.battery</td>
293</tr>
294
295<tr>
296<td>Accelerometer</td>
297<td>Whether there is an accelerometer in the device. Default value is "yes".</td>
298<td>hw.accelerometer</td>
299</tr>
300
301<tr>
302<td>Audio recording support</td>
303<td>Whether the device can record audio. Default value is "yes".</td>
304<td>hw.audioInput</td>
305</tr>
306
307<tr>
308<td>Audio playback support</td>
309<td>Whether the device can play audio. Default value is "yes".</td>
310<td>hw.audioOutput</td>
311</tr>
312
313<tr>
314<td>SD Card support</td>
315<td>Whether the device supports insertion/removal of virtual SD Cards. Default value is "yes".</td>
316<td>hw.sdCard</td>
317</tr>
318
319<tr>
320<td>Cache partition support</td>
321<td>Whether we use a /cache partition on the device. Default value is "yes".</td>
322<td>disk.cachePartition</td>
323</tr>
324
325<tr>
326<td>Cache partition size</td>
327<td>Default value is "66MB".</td>
328<td>disk.cachePartition.size </td>
329</tr>
330
331<tr>
332<td>Abstracted LCD density</td>
333<td>Sets the generalized density characteristic used by the AVD's screen. Default value is "160".</td>
334<td>hw.lcd.density </td>
335</tr>
336
337<tr>
338<td>Trackball support</td>
339<td>Whether there is a trackball present.</td>
340<td>hw.trackBall </td>
341</tr>
342</table>
343
344
345<h2 id="moving">Moving an AVD</h2>
346
347<p>If you want to move or rename an AVD, you can do so using this command:</p>
348
349<pre>android move avd -n &lt;name&gt; [-&lt;option&gt; &lt;value&gt;] ...</pre>
350
351<h2 id="updating">Updating an AVD</h2>
352
353<p>If, 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 <code>android list targets</code> command will produce this output:
354
355<pre>The following Android Virtual Devices could not be loaded:
356Name: foo
357Path: &lt;path&gt;/.android/avd/foo.avd
358Error: Invalid value in image.sysdir. Run 'android update avd -n foo' </pre>
359
360<p>To fix this error, use the <code>android update avd</code> command to recompute the path to the system images.</p>
361
362<h2 id="deleting">Deleting an AVD</h2>
363
364<p>You can use the <code>android</code> tool to delete an AVD. Here is the command usage:</p>
365
366<pre>android delete avd -n &lt;name&gt; </pre>
367
368<p>When you issue the command, the <code>android</code> tool looks for an AVD matching the
369specified name deletes the AVD's directory and files. </p>
370