Running Your Application

Write App Reviews

Build your own Android App Dev Empire

Get Instant Access

Unless you'll be running your application on device hardware, you need to launch an emulator upon which you will install your application. An instance of the Android emulator runs a specific Android platform with specific device configuration settings. The platform and configuration is defined with an Android Virtual Device (AVD). So before you can launch your emulator, you must define an AVD.

If you'll be running your application on device hardware, please read about Developing On a Device instead. 1. Create an AVD

1. Open a command-line and navigate to your SDK package's tools/ directory.

2. First, you need to select a "deployment target." To view available targets, execute:

android list targets

This will output a list of available Android targets, such as:


Name: Android 1.1 Type: platform API level: 2

Skins: HVGA (default),




Name: Android 1.5 Type: platform API level: 3

Skins: HVGA (default),



Find the target that matches the Android platform upon which you'd like to run your application. Note the integer value of the id — you'll use this in the next step.

3. Create a new AVD using your selected deployment target:

android create avd --name <your_avd_name> --target <targetID>

4. Next, you'll be asked whether you'd like to create a custom hardware profile. If you respond "yes," you'll be presented with a series of prompts to define various aspects of the device hardware (leave entries blank to use default values, which are shown in brackets). Otherwise, press return to use all default values ("no" is the default).

2. Launch an emulator

From your SDK's tools / directory, launch an emulator using an existing AVD (created above):

emulator -avd <your_avd_name>

An instance of the emulator will now launch, running the target and configuration defined by your AVD.

3. Install your application

From your SDK's tools/ directory, install the .apk on the emulator:

adb install /path/to/your/application.apk

If there is more than one emulator running, you must specify the emulator upon which to install the application, by its serial number, with the -s option. For example:

adb -s emulator-5554 install /my/project/path/myapp.apk

4. Open your application

In the emulator, open the list of available applications to find and open your application.

If you don't see your application on the emulator. Try restarting the emulator (with the same AVD). Sometimes when you install an Activity for the first time, it won't show up in the application launcher or be accessible by other applications. This is because the package manager usually examines manifests completely only on emulator startup.

Tip: If you have only one emulator running, you can build your application and install it on the emulator in one simple step. Navigate to the root of your project directory and use Ant to compile the project with install mode: ant install. This will build your application, sign it with the debug key, and install it on the currently running emulator. If there is more than one emulator currently running when using the install command, it will fail — it can't select between the multiple emulators.

For more information on the tools used above, please see the following documents:

android Tool

Android Emulator

Android Debug Bridge (ADB)

Was this article helpful?

0 0

Post a comment