Pages

Showing posts with label AVD. Show all posts
Showing posts with label AVD. Show all posts

Thursday, June 2, 2011

Create Android Virtual Device (AVD) in command line

In the article How to create Android Virtual Device (AVD) in Eclipse and Create an SD Card to existing AVD, I described how to create AVD in Eclipse and how to add SD Card to existing AVD. In this article, I describe how to create AVD, with SD Card, in command line (Terminal of Ubuntu Linux).

Environment:
OS: Ubuntu Linux 9.04
Android SDK 1.6 r1

- Before create AVD, you have to check the available system image targets in your system.

Start Terminal, switch to the tools folder of the installed Android SDK, it's ~/android-sdk-linux_x86-1.6_r1/tools in my own setup. Type the command:
$./android list targets



- Now you can create a new AVD, eg. a new AVD base on Android 1.6 (ID = 2), with 1000M SD Card.

Type the command:
$./android create avd -n my_android1.6_for_scripting -t 2 -c 1000M

You will be asked: Do you wish to create a custom hardware profile
Press Enter to answer NO.

After a while, the new AVD will be created.

- Start Emulator with the new AVD
$./emulator -avd my_android1.6_for_scripting

Friday, May 20, 2011

Create SD Card in Android Emulator and copy files into, in Eclipse, Emulator and DDMS.

In my previous articles, I described how to Create an SD Card to existing AVD, and Copying Files to a Disk Image in ubuntu host system using text commands in Terminal.

Now, I have another approach using in Eclipse, Emulator and DDMS. May be it's more easy, at least no need to remember the text commands.

Create a new AVD in Eclipse:

- Start Eclipse, click Window on the top menu, and click Android SDK and AVD Manager.

- New a AVD


- Name your new AVD, select Target, type 1000M in SD Card and select skin. Click Create.
note: SD Card must be either a file path or a size such as 128K 0r 64M. type 1000M now to create a SD Card of 1G.

- Select and Start the new AVD.


After the Emulator started, you can close the AVD Manager.

Create folder in SDCard

I can't find any File Manager in Android Emulator. Fortunately, Android Emulator provide a DevTools with Terminal, so you can create a folder using Linux command inside Android Emulator.

- Click the ARROW on the screen to display the available application.

- Click DevTools.


- Scroll down to start Terminal Emulator


- It's the same a terminal in Linux, you can ls to view the current files and folders in your $home.


- Now change into sdcard and create a folder, say pictures.
$cd sdcard
$mkdir pictures

It's the only two line of command in this approach.


Copy files from your host system into Android SDCard

- With the Emulator is running. Now go back to Eclipse, switch to DDMS Perspective

Click the arrow on the menu bar and select DDMS

or

Click Window > Open Perspective > others > to select DDMS

- Select the device in the window on the left, eg. emulator-5554.
(Without select the device, you will fail in copying files into.)

- In DDMS, select File Explorer tag in the window on the right. Expend sdcard folder. Now, you can see the pictures folder in the tree. And also, you can see the Permissions of the folder.


- Select the pictures folder, and click Push a file onto the device .

- Browse to and select the files from your host, to push onto the Android Emulator.

- Further expend the folder pictures, you can see the new file here.

Create an SD Card to existing AVD

Here, I want to create an SD Card image to an AVD.

- Firstly, locate the path of your AVD, type the command in Terminal:
$android list avd

- Create a SDCard image, named "sdcard.img" (it's the default name for the emulator to load).
In my case, I want to add 16M SD Card to the /home/eric/.android/avd/my_avd_GoogleAPIs_1.5.avd.

$mksdcard 16M /home/eric/.android/avd/my_avd_GoogleAPIs_1.5.avd/sdcard.img

where /home/eric/.android/avd/my_avd_GoogleAPIs_1.5.avd/ is the path of my avd.



Restart the emulator, click Menu in Android Home screen, then click Settings > SD Card & phone storage. Now, you can see the SD Card here.

With 16M SD Card:


Without SD Card, before adding the SDCard image:

Popular Posts