How to make your first Android App from scratch

Follow these 5 steps to make your first Android app.

Vatsal Patel
Nerd For Tech
8 min readSep 27, 2021

--

Android App development is a process of developing Native Android apps that might seem hard in the beginning, but it can open up a world of possibilities. It is hard to find where to start from, but don’t worry this is the perfect article for a practical example to make your first running app used on a mobile phone.

If you are confused or want complete knowledge of Mobile Development read this article.

To develop an app in the Android Studio you need to learn programming language either Java or Kotlin.

It’s a different topic of discussion to choose which language but I will give a brief overview. Java is one of the most popular programming languages that was Google’s preferred language for Android some time ago. Many apps run on Java and is used even today. Best thing is it has also got a ton of examples and rich tutorials for every topic of android that helps a beginner to learn fast.While Kotlin is a new emerging language currently preferred by Google. It is easy to learn and has got some edge over Java. Also, it reduces the length of code and removes some of the most famous “Null Pointer Exception” and other Java runtime errors beforehand.

After deciding which language to learn and getting used to language next step is to get an overview of Android, its SDK, and Development tools before starting Android Studio, so you don’t get confused on the first look. After learning the basics of Android and gaining knowledge of various features and functions of Android Studio, you can go forward to make the first practical app.

Following are the 5 steps required:

1. Download tools required for app development

You need to set up the environment in which you will develop the app. Android Studio is an Integrated Development Environment required for android development. It is the complete package including SDKs, Emulator, UI Designer, Program Editor, Compiler, and Debugger all in one. It is important to know that you will need to download some SDKs and the emulator after the installation of Android Studio.

You can download Android Studio from here

2. Create New Project

Here starts your journey with Android Studio.

After successful installation of Android Studio, launch the program and you will see the first screen as shown above. Click on Create New Project.

It will lead you to the next screen as above. This page provides the standard prebuilt templates from which you can choose any as per need instead of creating them. Though these templates are helpful for developers, we will go with the Empty Activity as other templates might confuse at this we are starting for the first time. Now click on Next.

It will lead you to the final step of project setup as above. This page is to set up the general specifications of your project. As shown in the image it asks the Name of the project (eg: First App) and Package Name (eg: com.example.FirstApp). The package name is an internal reference used by Android to differentiate it from other apps. It should be composed using your top-level domain (eg: .com), domain or organization name, and app name. For now, as we have no organization we keep it default and choose Location for saving the project.

It is necessary to choose any of two languages (Java/Kotlin) with which you are comfortable. It will be selected as the default language for the project, though you can customize your files later. After that, you need to select the Minimum SDK for the project. If you got familiar with Android you would know it else for short it is the version of Android from which you want to support up to the latest version. Then click on Finish to create the project.

3. Introduce Yourself to the Interface

It might seem confusing to see all these buttons and windows within each other together. But don’t worry, it happens with all and slowly we get used to it. Our main focus is to make and run a simple app. Following are some images of commonly used windows in Android Studio with descriptions.

It is the main screen visible by default. It shows the Code Editor along with Navigation Panel for all your Project Files. Switch files view to Android as in beginning more files might confuse you so keep it simple. The Topbar contains the majority of options and functions of Android Studio. The Bottom bar contains some of the handy tools essential for testing, debugging, etc.

It is the UI(Layout) development screen. From here you can edit and see everything related to the looks of components of your app. Here you can find every element that Android supports Left side. While on the Right side, it shows all properties of the selected UI element. On the Top Right corner of this window, you can see 3 buttons with Code, Split, and Design headings. You can switch the view by clicking those buttons and the result of that click is shown below.

This layout is visible on clicking the Split button that consists of both the design and code of layout. You might be wondering what is this code for? UI in android is based on XML coding. It can is achieved by simple Drag and Drop as shown above or by learning to code UI. Coding the UI elements will be faster and give you more control as you move forward in development.

As visible in this image, a window is opened from the Bottom bar called Logcat. It is an essential tool for app development because it shows all reports of your app when it is running on a device or emulator. It is especially useful to find the reason for app crashes which will occur numerous times while developing.

This window will be visible when you press a button named No Devices in Topbar and then clicking AVD Manager (Android Virtual Manager). From here, you can install a virtual emulator for testing the app.

I would recommend going with an Android device instead of an emulator if possible as this is a slow and resource-intensive process that your computer might not support or may perform laggy.

4. Let’s Start Coding

Ok, after enough intro, let’s start making the app as above we will add a Button in the layout and constraint into sides of the app so that it remains in a fixed position. Also, we would increase the text size of the text view that was already there. Now we will provide ID to text view and button. It is necessary for every UI element as it gives them an identity to reference in code and differentiate from each other while coding.

You can also paste the code provided below for testing.

After setting up the UI part, let’s add the necessary code to make those elements functional. As shown in the image, we will first create a variable as an Instance of the elements we want to program they are mTextView as an instance of Textview and mButton as follows.

TextView mTextView;
Button mButton;

Now we need to connect them to their ID that we gave before so that they connect with their UI part with the “findViewById()” function that finds a specific view(element) by the given id.

mTextView = findViewById(R.id.textview);
mButton = findViewById(R.id.button);

We want to change the text of text view on button click to show “My First App is running great”. So to listen to the click on the button, we need to add “OnClickListener()” on the button.

mButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//write your code here
}
});

The code written in the block will execute on a button click. As we want to change text we chose the “setText()” property of the view.

mTextView.setText("My First App is running great");

You can paste the code provided above for testing.

5. Running The App

After completing the necessary code we need to build and run the app. As shown in the image above device name or emulator is connected and click on the triangle Play button next to it. It will build and install the app on your device. You can click the button and check it.

Here is the proof that the app works as we wanted.

Hurray! We made our first working android app. Wasn’t it simple? You do not need to be a Pro to start developing an android app.

Next Steps

Ok, I made a basic app, it was easy, but how can I make professional apps? It was a simple demonstration of setup and go-through of how to run an app in Android Studio. Your next steps are to learn Flow Controls, Collections, OOP concepts, etc in language and get knowledge of all UI elements and test them just like we did.

Slowly and steadily you will get a good understanding of Activities, Fragments, Services, etc components of Android Framework and how to use them. You can’t learn everything instantly also it is not the correct way either. As you starting making projects or working on other’s projects you will discover new concepts.

“Learning is a never-ending process”

and “Empires are not built in a day”

So keep patience and try learning new things.

Note: Images used in this article except the cover image are captured by me.

If you find this tutorial helpful please appreciate it below. Thank you :-)

If you want to talk more or any queries are left unanswered you can connect with me via -

- Linkedin

- Twitter

--

--

Vatsal Patel
Nerd For Tech

I am an Electronic Engineer, an AI Enthusiast, an Android developer and an Investor :)