Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Running Android Apps on Emulator

0.00/5 (No votes)
26 Nov 2012 1  
This article demonstrates running Android applications on emulator.

Sample Image

Sample Image

Introduction

This is basically a non-programming article in which I am describing how to install Android apps on an emulator.

Many times we come across situations when we cannot run a much liked Android application on a device. Either we do not have a device to test our application, or we do not have space to install the application on our device, or simply we want to test an application before installing it on our device. In such cases, the emulator provided by the Android SDK comes to the rescue.

In this article, I will show how to create an SD card to be used by the Android emulator, how to mount the SD card and copy applications to the SD card. Once the app is copied to the emulator, it can be installed in the same way as installing on a real device. I am assuming here that the Android SDK has been installed on the computer.

As an example, I am showing how to install the AngryBirds game on the emulator.

Background

First we have to create an SD card to be used by the emulator. For this, navigate to the "tools" directory of your Android SDK installation on the command prompt and type the following command:

mksdcard -l MYSDCARD 2000M F:\Software\android\mysdcard.img

The above command creates an SD card called mysdcard.img with a capacity of 2GB. The -l option specifies the label for the SD card.

After that we need to load the SD card while starting the emulator. For this, the following command can be used:

emulator -sdcard F:\Software\Android\mysdcard.img -avd MyDevice -scale 0.75

In the above command, the -sdcard option specifies the path of the SD card, the -avd option specifies the virtual device, and the -scale option specifies the relative size to scale the emulator.

The emulator starts as follows:

Next we have to copy the required apps to the SD card. For this, navigate to the "platform-tools" directory of the Android SDK, while the emulator is running, and type the following commands, replacing the file names with file names of your choice:

adb push F:\AndExplorer.apk sdcard/
adb push F:\AngryBirdsRio.apk sdcard/

Note: The / at the end of SD card is mandatory.

I prefer to install a file manager (e.g., AndExplorer.apk) before other apps so that installing other apps becomes easier by navigating to the SD card using the file manager.

Once the required files are copied to the SD card, we must install the file manager. Now the question is how to install the file manager itself without being able to browse to the SD card. The solution is to start the internet browser and type the following in the address bar:

file:///sdcard/AndExplorer.apk

The following screen appears:

Clicking the Install button will install the AndExplorer app. If we now browse the installed apps on the device, we get the following screen:

Now we can use the AndExplorer app to navigate to the SD card and view the contents as follows:

Clicking on the AngryBirdsRio.apk file will show the following screen:

Clicking the Install button will install the AngryBirds app and it will be listed in the installed apps as follows:

The following screens show the game in action on the emulator: (You can press the Ctrl-F12 key combination on your computer to change the orientation of the emulator).

Points of Interest

The android emulator provides an excellent environment to test apps before deploying them to the device. Hopefully this discussion will be useful to readers.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here