The Android emulator

Launching the emulator

In my previous post I demonstrated how to install the Android SDK, how to create a virtual Android device and how to install an Android application.  Once you have created an Android virtual device and named it, you don’t have to run the full SDK manager each time.  You can run your android device directly by starting just the emulator.   The emulator is another tool in the SDK.

First, lets add the tools folder from the android SDK to our $PATH for convenience.   Add the following to the end of your ~/.bashrc file.

export PATH=${PATH}:~/android-sdk-linux_86/tools

Run the emulator from the cmdline and give it the name of your saved Android virtual device.  If you remember from my previous post, I named mine fakeDroid.  Notice that you have to use the @ symbol with the name of your device.

$ . ~/.bashrc

$ emulator @fakeDroid

To make this even easier you can create a launcher on your Gnome desktop.  Right click on your Gnome desktop and select “Create Launcher…”.  For the command, put the full path to the emulator program and then the name of your saved Android device @fakeDroid.

That will create an icon on your desktop, that will launch your Android virtual device.

Creating SD cards

If you want to create virtual SD cards to use with your Android emulator, there is a tool for doing that called mksdcard.  The tool will create a blank FAT32 image file, that will emulate an SD memory stick.

The following command creates a 1GB SD card with a label “stick1”.

$ mksdcard -l stick1 1024M ~/sd_card_1G.img

You can copy files into your SD card by mounting it with the loop device.

$ sudo mount -oloop ./sd_card_1G.img /mnt

$ sudo mkdir /mnt/Pictures

$ sudo cp /opt/Pictures/*.jpg /mnt/Pictures

$ sudo umount /mnt

You can start your Android device with your SD card already mounted

$ emulator -sdcard ~/sd_card_1G.img @fakeDroid

One thing you may notice is the poor performance you get reading and writing the virtual SD card with your emulator.  You can boost performance dramatically by storing your SD image file in tmpfs.  I’ll demonstrate that in my next post.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s