Table of Contents
Overview
In this chapter you will put together everything you prepared in the previous sections and build a complete, very simple Android app from scratch. The goal is not to create something complex, but to experience the full journey from an empty screen to a running app on an emulator or device. You will see how a new project is created in Android Studio, how the default MainActivity ties things together, and how to run and debug your code.
By the end of this chapter you should feel comfortable starting Android Studio, creating a project, finding your way around the most important files, and running your app.
What You Will Build
For your first app you will create a basic "Hello" style application. It will have a single screen with some text. You will run it, see it appear on an emulator or device, and then make a small change so you can confidently verify that your edits are reflected in the running app.
This first app is intentionally very small. The focus is on learning the steps, tools, and flow of development rather than building a feature rich product.
Creating a New Android Project
To begin, you will start Android Studio and create a new project. The exact appearance of the dialogs can change slightly between Android Studio versions, but the overall process stays the same.
You start by choosing the option to create a new project. Android Studio offers template screens, such as an empty activity or basic activity. For this first app, you select the simplest one that gives you a single screen and a Kotlin Activity class, usually called an "Empty Activity" template.
After choosing the template, you configure some basic project details. You enter an application name, such as "MyFirstApp". This is what users will see on their device home screen. Android Studio also asks for a package name. For beginners, you usually keep the suggested default, such as com.example.myfirstapp. This package name uniquely identifies your app on a device and in the Play Store.
You also make sure the language is set to Kotlin, since the course focuses on Kotlin for Android. Then you choose the minimum Android version you want to support. The dialog usually shows a recommendation and tells you what percentage of active devices you cover if you pick a specific version. For your first app, you can accept the suggested minimum version so you do not have to think about compatibility yet.
Finally, you choose a location on your computer where the project files will be stored. After you confirm, Android Studio creates the project. It sets up folders, configuration files, and some starter code for you. This can take a moment as Gradle, the build system, finishes its initial setup and downloads needed components.
Once the project loads, Android Studio shows you the main editor window. By default, you usually see the MainActivity Kotlin file or the layout XML for the main screen.
Meeting Your First Activity
The template project includes a single Activity class that represents the first screen the user sees when the app starts. By default this is usually called MainActivity and extends a base class from the Android framework. You do not need to understand all the details of how activities work yet, since activity lifecycle and callbacks will be covered later. For now, it is enough to know that this class is the entry point of your app´s user interface.
Inside MainActivity you find a function that is called when the activity is created. In this function, the code connects the Kotlin class with your screen layout. The layout is defined in an XML file, typically named activity_main.xml. This XML describes the visual structure of the screen, such as a TextView that displays "Hello World".
The important idea at this stage is that Kotlin code in MainActivity and the XML layout work together. The activity controls the behavior, while the layout describes how things look. When the activity is started, the system calls your code and your code tells Android which layout file to use. As a beginner, you can open the layout file and edit the text to prove to yourself that changing the XML changes what you see on screen.
Exploring the Default Layout
After project creation, open the layout file for the main activity, usually found under a res/layout folder. Android Studio provides both a visual design view and a code view. In the design view you see a preview of what the app screen looks like. In the code view you see the actual XML.
The template layout generally contains a root layout and a TextView with text set to "Hello World". You can click on the TextView in the design preview and change the displayed text in the properties panel, or switch to the XML and edit the android:text attribute directly.
For example, you can change the text from "Hello World" to something like "Hello Android". After doing this, the preview updates. When you next run the app, this is the text you will see on your device or emulator. This gives you your first feedback loop. You edit the layout file, build and run the app, then visually confirm that your changes appear.
Building and Running the App
To see your app in action, you need to run it on either an emulator or a physical device. You should already have an emulator or device prepared from the environment setup topics, so here you focus on how to start the app from within Android Studio.
At the top of the Android Studio window there is a run configuration area. The default configuration is usually already set up for your app and points to app with a launch activity of MainActivity. Next to this there is a device selector where you can choose a connected physical device or a virtual device. From the drop down you select the emulator or phone you want to use.
To run your app, click the Run button, which looks like a green triangle. Android Studio then triggers a Gradle build. It compiles your Kotlin code, processes resources such as layouts and images, and packages everything into an Android application package. This is then installed on the selected device or emulator, and the specified activity is launched.
The first build can take some time, especially on a fresh setup. You can watch progress in the "Build" tool window. When deployment finishes, the emulator or device displays your app. If you changed the TextView text earlier, you should see your custom message instead of the default "Hello World".
If you do not see the expected output, you can check that you saved your XML changes, that the correct layout is used by MainActivity, and that the right device is selected.
Making and Testing a Small Change
To build confidence, it is helpful to make a simple change and run the app again. Open the layout XML and adjust the text once more, or change the text size or color through the properties in the design editor. Then press the Run button again.
Android Studio will notice that only resources changed and may build faster this time. Once the app is redeployed or updated on the device, you will see the new version of your text. This quick cycle of edit, run, and verify is at the heart of everyday Android development.
If you keep the app already running on the device, some changes can be applied faster using tools that Android Studio provides for quick deployment. These tools aim to avoid a full reinstall whenever possible. The idea is that your workflow should feel interactive and responsive while you iterate on your UI.
Introducing Debugging in Context
After you have seen your app run successfully, you can take a brief look at how debugging fits into the picture, without going deep into details that belong to later chapters. Android Studio lets you run the app in a special debug mode, which is started from a button similar to Run, usually represented by a green triangle with a bug symbol.
When you start your app in debug mode, you can inspect what is happening while it runs. Even for a very simple first app, you can open the Logcat window and see messages produced by the system and by your app. You will explore debugging tools extensively in a later dedicated chapter, so at this stage it is enough to know that debugging exists and that you will use it to track down issues and understand app behavior.
For now, focus on successfully creating, running, and slightly modifying your app. This foundation will make debugging feel natural when you learn it in depth.
Understanding the Build and Run Cycle
Every time you press the Run button, a small chain of events happens. Your project is built, an application package is created, then it is installed and launched on the target device. This is your basic development loop.
You edit code or layouts in Android Studio. You save your changes. You select a target device. You run or debug the app. Finally, you observe the behavior and appearance on the device, then return to the editor to adjust things further.
Always verify that you are running the latest version of your code and resources by saving your files and watching the build result before judging what you see on the device.
This simple rule helps avoid confusion where the app on the screen does not reflect your most recent edits.
Building Confidence with Experiments
Once your app runs and you can change the text, try a few small experiments. You can reposition the TextView using the design tools, or set a different string in the layout. You might give the app a different display name in the project settings so that it appears under a new name on the device launcher.
Each small experiment reinforces the idea that you control both behavior and appearance through the project files and Android Studio tools. Your first app is not meant to be polished or complete. Its purpose is to give you a safe space to experiment and learn how the tools respond.
In future chapters, you will extend this foundation. You will learn how MainActivity really works, how to design better layouts, how to respond to user interaction, and how to manage app state across the Android lifecycle. For now, you have successfully created and run your first Android app, which is an important milestone on your journey.