page.title=Running Your App parent.title=Building Your First App parent.link=index.html trainingnavtop=true page.tags=emulator helpoutsWidget=true @jd:body
If you followed the previous lesson to create an Android project, it includes a default set of "Hello World" source files that allow you to immediately run the app.
How you run your app depends on two things: whether you have a real device running Android and whether you're using Android Studio. This lesson shows you how to install and run your app on a real device and on the Android emulator, and in both cases with either Android Studio or the command line tools.
If you have a device running Android, here's how to install and run your app.
Note: On Android 4.2 and newer, Developer options is hidden by default. To make it available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options.
Android Studio installs the app on your connected device and starts it.
ant debug
platform-tools/
directory is included in your
PATH
environment variable, then execute:
adb install bin/MyFirstApp-debug.apk
That's how you build and run your Android app on a device! To start developing, continue to the next lesson.
Whether you're using Android Studio or the command line, to run your app on the emulator you need to first create an Android Virtual Device (AVD). An AVD is a device configuration for the Android emulator that allows you to model a specific device.
Figure 1. The AVD Manager showing a virtual device.
<sdk>/tools/
and execute:
android avd
When you select a device type, most of the fields auto-populate.
It really doesn't matter what you enter here since you're not using any storage. But if you reuse this AVD, you might have to adjust this setting.
It can take a few minutes for the emulator to load itself. You may have to unlock the screen. When you do, My First App appears on the emulator screen.
ant debug
platform-tools/
directory is included in your
PATH
environment variable, then execute:
adb install bin/MyFirstApp-debug.apk
That's how you build and run your Android app on the emulator! To start developing, continue to the next lesson.