Run on the Emulator
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.
Create an AVD
Launch the Android Virtual Device Manager:
In Android Studio, select Tools > Android > AVD Manager, or click the AVD Manager icon in the toolbar. The AVD Manager screen appears.
Or, from the command line, change directories to sdk/ and execute:
tools/android avd
Note: The AVD Manager that appears when launched from the command line is different from the version in Android Studio, so the following instructions may not all apply.
On the AVD Manager main screen, click Create Virtual Device.
In the Select Hardware window, select a device configuration, such as Nexus 6, then click Next.
Select the desired system version for the AVD and click Next.
Verify the configuration settings, then click Finish.
For more information about using AVDs, see Managing AVDs with AVD Manager.
Run the app from Android Studio
In Android Studio, select your project and click Run from the toolbar.
In the Choose Device window, click the Launch emulator radio button.
From the Android virtual device pull-down menu, select the emulator you created, and click OK.
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.
Run your app from the command line
Build the project from the command line. The output APK for the app module is located in
app/build/outputs/apk/.
Make sure the Android SDK
platform-tools/
directory is included in yourPATH
environment variable.Execute this command:
$ adb install app/build/outputs/apk/apk-debug.apk
On the emulator, locate MyFirstApp and open it.