Your First Kotlin Android App: An App From Scratch

Aug 15 2023 · Kotlin 1.8.20, Android 13, Android Studio Flamingo | 2022.2.1

Part 1: Get Started with Android Development

05. Run the App

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 04. Setup a Project in Android Studio Next episode: 06. Get Started with Jetpack Compose

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Transcript: 05. Run the App

You now have a brand new project with Android Studio. To test out your app and make sure it works, you have to build it and then run it. Building a project is part of the development process usually handled by an IDE like Android Studio.

The building process involves compiling your code and packaging any assets like images and other related files into an APK file, which is a program that can run on an Android device.

To run your app, the Android development environment provides us with a piece of software known as an emulator or sometimes called a simulator. As the name suggests, it emulates a real device for us to test our applications during development.

This is a convenient way to test and interact with the application you’re developing. These virtual devices are managed in the Device Manager section of Android Studio.

I already have emulators set up, but I’ll show you how to add an emulator.

To install a new virtual device, click on the “Device Manager” button in the toolbar above. You can also find the device manager in the window navigation bar on the right side of the screen.

You can see the list of virtual devices I already have on my machine. Go ahead and click on the “Create device” button.

This opens up the virtual device configuration dialog.

In here, you could set up an emulator for different virtual devices like phones, tablets, TV, and even automotives. The phone category is selected by default, and that’s what we’ll be working with in this course. So go ahead and browse through the list and select any device of your choice.

It’s essential to test on multiple screen sizes to avoid unexpected layout issues with your app. An emulator gives you the freedom to do so because you can install devices with different screen sizes to test out your app.

I’ll select one with the screen range of 5 to 6 inches. I prefer to work on smaller screens then adapt to bigger devices.

After you make your selection, click “Next”. This brings up a list of system images, which are the different Android versions that you can install on the virtual device.

Select Tiramisu, which is the codename for Android 13.

Most of the time, these system images are not installed on your machine, so you’ll have to download them. You’ll see a download icon beside the name just like we have in other versions.

When you click it, a popup that shows the installation process is displayed. Once it’s done downloading, you hit the finish button.

But I already have the Android 13 system image on my computer, so I don’t have to do this step. So I’ll just select it then click next, which brings us to the final screen.

In here, we can verify the configurations of this device to make sure it is what we want. Leave everything as it is and click the “Finish” button.

This creates the virtual device and adds it to the list of virtual devices on our machine.

Now that you’re done installing the emulator, it’s time to run the app.

Click on the dropdown beside the icon that looks like a play button up in the toolbar. It doesn’t matter which one is selected for now, but you see there are available devices to test out your app. You can select the one you just installed.

Now go ahead and click the run button, which is the green play button beside the devices dropdown.

Android Studio begins building the Bullseye app and installs it on your selected device. If you look at the bottom of the screen, you’ll see the process displayed in the status bar.

The status bar in Android Studio is used to inform developers about the processes running in a non-obstructive way. So keep an eye on that section.

When Android Studio is done building and installing Bullseye, the app would appear on your device.

And there you have it! Your first Android application is up and running.

Now, before we end this episode, my hands are feeling a bit itchy to dive into the code. You’ll do something easy for now.

Take a look at the screen; it says “Hello Android.” You’ll be making the app your own. You will display your name instead.

You should have the MainActivity.kt file open if you have been following along. Else, you can easily locate it in the project directory in the Project Navigator panel.

Don’t worry about what this file does for now; you’ll learn more about it in the next episode.

If you look closely, you see the “Android” greeting text that is displayed on the app screen.

Update the value to say hello to yourself. I’ll go ahead and add my name like so:

Greeting("Emmanuel")

Make sure you don’t remove the double quotes around the text.

Now it’s time to run the app.

But wait!!! What just happened? The app is already updated with the new greeting text without us having to run the app again. Well, that’s live edit at work. It simply updates your app in real time when you make changes inside your composables.

And there you have it. The Bullseye app now displays a name in the greeting text. Let’s learn about what composables are in the next episode.