Wednesday, 16 May 2012

Android emulator - Creates the sdcard

The android's emulator is an emulator that emulates an android device. Through the AVD manager, the user can create an emulator that runs any version of Android.

To passes data to the emulator, one could creates an fake SD card in the computer and passed it to the emulator. Later, this SD card could be used to exchange data.

To use a SD card in the emulator, there are two ways
1. Creates the SD card with the emulator
This is the easiest option. The SD card is created with the emulator, thus it will be always associated with it. To create it:
1.1 Open eclipse
1.2 Click on Windows -> AVD manager
1.3 Click on New
1.4 Enter a name, a target (The version of the android) and on the SD card part, specify the size of the SD card. It could be 256MB, 512MB, etc
1.5 Creates on Create AVD

After it, the emulator has been created with the SD card.
Normally, the SD card is localized on C:\Documents and settings\USERNAME\.android\avd\AVDNAME.avd\ (In case of Mac OS, on \Users\USERNAME\.android\avd\AVDNAME.avd\)

2. Creates the SD card outside of the emulator
2.1 Open the terminal
2.2 Go to the android SDK plugin directory
2.3 Go inside the folder "tools"
2.4 Type on the terminal
./mksdcard 256M sdcard.iso

This command will creates a blank disk image file of 256M on the actual folder. The minimum size of the SD card is 9M and the maximum size is 1023GiB. You can use "K", "M" or "G" to specify the size in Kib, MiB or GiB, respectively.

The another option is that you can specify where the disk image file should be. The follow command creates a disk image file on the directory of /Users/jiahaoliuliu/

./mksdcard 256M /Users/jiahaoliuliu/sdcard.iso

Once the sdcard is done, each time you runs the emulator, you can specify the sdcard by adding the following command in the run configuration

-sdcard /LOCATION/OF/SDCARD/sdcard.iso

No comments:

Post a Comment