Creating Your First Android App

In this tutorial you will see how to create a fresh new Android app and then will learn how to run it on your actual device and how to set up and run it on an emulator for debugging.

Step 1: Start a new Android Project

Open Android Studio and select Start a new Android Studio Project.

Starting Android Studio

Step 2: Application Name & Company Domain

Choose a name for your application. This name is the name displayed in the app drawer in the users phone.
Also choose a company domain name which usually is your comapny’s website URL.

Choosing Name

Step 3: Choosing Target Android Devices

Choose the minimum Android version that you want your app to work on. Choosing an older version allows your app to work on most devices but may hamper the capabilities of your app.
Depending on your need you can choose an appropriate android version. Since this is just a simple sample app you can choose a higher android version for this app.

Target Devices

Step 4: Adding an Activity

In an app everything happens in an activity (except those apps that work in background, we will come back to those later). You will add a launcher activity now. This activity is called when the user opens up your app from the app drawer. Though its not necessary to add an activity right now as activities can be added later too. But for this sample app we will use an Empty Activity.

Add Activity

Step 5: Customizing the Activity

Next you need to give the name of the Empty activity added and the name of its associated layout file.
For this sample app you can give it the default name or you could choose any name you like.

Customize Activity

Step 6: Running The App On Your Device

After doing the last step you can now directly run the app as the android studio makes all the necessary files and codes to make a simple hello world app.

To run it on your device, first you will need to enable the USB debugging option in your device’s settings. Go to Settings->Developer Options->USB Debugging.

Some devices have the Developer Options menu hidden, if you can’t find Developer Options then that can be the case. To make it available on your device you have to go to About Phone and tab on the Build Number seven times to enable the Developer Options.

After enabling the USB debugging connect your device to your pc and Run the app by going to Run->Run ‘app’

Run App

It will show you the available devices. From the list select the one you want to run the app on.

Available Devices

Step 7: Creating an emulator and running app on emulator

At times you may not have access to an actual android device to run your application for debugging in such cases you can use an emulator or Android Virtual Device(AVD) for running and debugging apps.
To create an Android Virtual Device or Emulator. Go to Tools->Android->AVD Manager

Tools AVD Manager

Once Android Virtual Device Manager opens up select Create Virtual Device.

AVD Manager

Then select the devices you want the emulator to mimic. Or you can create your hardware profile. After that click on next.

Selecting Hardware

Then Select the android version you will like the device to have you can use an available system image or you can download the one you will like to use.

System Image

Now you can verify the configuration selected and change some settings you like such as how much RAM should the emulator, the scale factor, the name of the emulator. Its best to leave all that at the default value if you are doing it for the first time. Then press finish to create an AVD.

AVD config

AVD created

Double click on the AVD or press the green play button to start the AVD. The first time it starts it will take longer time than usual.

AVD Running

Now you can run the app in your emulator by going to Run->Run ‘app’. Then selecting the AVD you just started from the list of available devices.

Available Devices

App Running

You could use the emulator for running and debugging your app on your pc itself. Though it is better to use an actual device.

This content has been helpful to you?

Thanks for contributing!

Yes No