We have our first app (displaying Hello world!) without coding anything. Before we start developing something more, let’s check how this simple app works. This is very easy – we will use built in emulator of a mobile device. The emulator is a special application which would simulate a real Android device (including original system behavior and hardware behavior) on a computer.

It’s not 100% perfect, but it’s the only way to test your app on most typical devices without having them physically. You could imitate both smartphones and tablets with various equipment and system.

Step 1: Choose Run | Run ‘your app name’ from menu or just press Play icon in submenu (it could take a few second at the first time).

Run options allows to run your app on virtual or real device (Android Studio)

Step 2: In the window Choose Device we have two options: Choose running device (this is for real devices) and Launch emulator which would simulate a device on your computer. To use emulator first we have to create virtual device. So click an ellipsis button (three dots) next to the yet empty list of devices.

There aren’t yet any virtual devices available so first we have to create one (Android Studio)

Step 3: We have opened Android Virtual Device Manager which allows to create many different virtual smartphones and tablets. At the moment we need just one so click New.

Android Virtual Device manager is standalone program in which you could create simulators of many various smartphones and tablets.

Step 4: In window Create a new Android Virtual Device (AVD) you have to fill a name of device and choose its size and resolution from Device list. It’s good practice to write as a name a type of device, screen size in inches and screen resolution, for instance Smartphone_4_480_800 (mind that only some characters are permitted in a name). For some devices from the list you have to set Target as well (Target is a preferable version of Android system) – choose the highest (newest) available. The rest of options leave as they are. Click OK. There would be summary of created device. Click OK.

There are many predefined devices – you should easily find one you want or just choose the one similar to current market standard (Android Virtual Device)

Step 5: Now you see your virtual device in Android Virtual Device Manager – you could close that window. Go back to Choose Device window and choose the device you have created and click OK.

As we have now the virtual device, start the emulator (Android Studio)

Step 6: Virtual smartphone is starting. Depending on your computer performance it could take a few minutes. Wait until you will see your app on the screen.

At the beginning we just see an empty console – computer needs a few minutes to create a simulator of a real device.

Great job! Our app is working. We could now use it as on the real device. But because it just displays text all we could do is closing and opening it. Cool, isn’t? (Android Emulator)

By the way – there is now a new window opened at the bottom of Android Studio that so messages related to run process, but we don’t need it now.

Android Studio displays status of the emulator, but we could hide it.

Step 7: You could use emulator as a real device. If you click Home button in the right panel of virtual phone you will see the main screen of the device (at the first time you will see some extra instructions). Now click Apps icon on the screen and you will see grid of installed apps including your app. Click it and you will open it again.

On the right part of the emulator are “hardware buttons” of the real device. For instance you could turn of the device or go to Home window. (Android Emulator)

Your app icon is among icons of preinstalled apps in you device. (Android Emulator)

If you want to see your app running on tablet, just create another virtual device. Keep in mind that tablet emulators uses even more of your computer resources so rather for simple testing basic apps it’s better to use smartphone emulator.

It’s useful to keep emulator running when you still improve your app. If you introduce some changes in the app, just click Run again. New version would be upload to your emulator and started. It’s much faster than starting every time an emulator.

What & Why

There are many Android tutorials for developers, but it is difficult to find easy to understand lessons for beginners. Android4Beginners.com explain how to build your apps step by step with clear instructions, examples and illustrations. Feel free to share your tips & tricks too!