Learn to install and configure Android Studio and make your first Android app using Java with this detailed tutorial.
Advertisement Advertisement Advertisement Advertisement Advertisement Aug 4, 2021 • 6 min readAre you a budding developer who knows the basics of Java and wants to make their first app using Android Studio? With the Play Store currently hosting 2.89 million Android apps and growing every minute, it's a great decision to learn and eventually master Android app development.
To make an Android app, you need an Integrated Development Environment (IDE), and Android Studio is the official IDE for creating Android Apps.
To install and get started with Android Studio, check out my post on How to Use Android Studio.
How to Use Android Studio
Arooha Arif 31 Jul 2021
Now that Android Studio is ready to use, you can start by creating your first project. Give your project a name and give it a unique package name too. Then, choose the minimum SDK you want to support with your app.
As it says beneath the Minimum SDK bar, with each API level, the features that you can use in your app increase. However, your app will run on fewer devices. The Create New Project dialog includes an estimator for the percentage of devices your app will run on.
You will then be asked to select the layout of your app. Let's choose Empty Activity so that we have a lot of room to experiment and learn.
Once you give your activity a name—let’s name it MainActivity for this tutorial—Android Studio will take a moment to create your first project. Now, you have in front of you the main code editor where you will be able to write the code for your app.
The big section on your right is the Editor Window, where you write the code of your app. On your left and below that are the tool windows. These let you easily navigate and work on a specific task of your project, for example browsing files or viewing debugging information.
The two bars that you see on top are the Toolbar, which allows you to perform common tasks in Android Studio, like building, running, and debugging apps, and the Navigation Bar, which lets you navigate through the project and the currently opened class file.
Take a few minutes to study the screen. It will make more sense once you start making an Android app with Java.
Now that you understand the basics of Android Studio, it is time to finally make your first Java Android app.
Now, if you look at the left side of your screen, you will see two folders. One of them holds your app’s code and is named after the title of your project. In this case, it would be MyFirstJavaApp. The other folder contains Gradle Scripts, which is a free tool Android Studio uses to turn your app’s code into .apk files.
First, you click to open the MyFirstJavaApp folder and access the code of your app. Then, you click on the app folder. This has three folders which hold different elements of your project: manifests, java, and res.
To start, select res, which contains a file called activity_main.xml. Clicking on this file will allow you to access the layout of your main Activity. On screen, it will look like this:
The empty Activity that we chose has a ConstraintLayout , which is the root of the hierarchy, as you can see on the screen. It has just one element, TextView , that says Hello World. The constraint layout is a container for the components of your Activity and helps keep them spatially organized.
You have two basic ways to make changes to your Activity layout:
The first method is great for you if you do not have much experience with writing code and your focus is learning to make a Java app using Android Studio. However, if you love to write code and want to get better at writing apps, the second method would be your way to go.
Now you have myriad options open. Let’s experiment with changing the TextView a little. Open the code editor to see the code of TextView element which is going to look like this:
Let’s change it to:
You can also change the text’s color and the font style, but I am not choosing to do that here. However, I have put the text in bold. Let’s run it on the AVD or the device to see how it looks.
Here is the code for these changes: