Running and debugging
Android applications can be run from Android Studio in a real device using a USB connection or in a virtual device using the emulator. Virtual devices make it possible to test our applications on different types of hardware and software configurations. In this chapter, we will use the emulator to run and debug our application because of its simplicity and flexibility.
To run an application directly, navigate to Run | Run 'app'. You can also click on the play icon from the toolbar. To debug an application, navigate to Run | Debug 'app' or click on the bug icon from the toolbar. If your app is already running, you can start the debug mode by navigating to Run | Attach debugger to Android process.
When we select the Debug 'app' option, a dialog to choose the device is opened. The Connected Devices section is used to choose a running device; the current connected devices are listed, real or virtual. The Available Emulators section is used to launch a new instance of the emulator...