Your First Kotlin Android App: An App From Scratch
Jul 5 2022 Kotlin 1.6, Android 12, Android Studio Bumblebee | 2021.1.1
Part 1: Get Started with Android Development
5. Build & Run the App
This video Build & Run the App was last updated on Jul 5 2022
We now have our brand new project with Android Studio. To test out our app to make sure it works, we have to build it and then run it.
Building a project is part of the development process usually handled by an IDE just like Android Studio.
The building process involves compiling our code and packaging any assets like images and other related files into an apk file, or a program that can run on an android device.
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 in order for us to test our applications while developing.
This is a convenient means 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 setup 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 by 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 “Create device” button.
This opens up the virtual device configuration dialog.
In here, you could setup an emulator for different virtual devices like Phones, tablets, TV and even automatives. The phone category is selected by default and that’s what we’ll be working on 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. And an emulator gives us the freedom to do so becasue you can install devices with different screen sizes to test out your app.
I’ll select one with the screen range of 5.0 to 6.0 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.
Most of the time, these system images are not installed on your machine so you’ll have to download them.
If you click on the download link for API 32 which is Android version 12. This will bring up a popup that shows the installation process. Once its done downloading you hit the finish buttton.
But i already have that android system image on my computer. 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. I’ll 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, its time to run the app.
Click on the dropdown beside the icon that looks like a play button up in the toolbar. It doesnt matter which one is selected for now but you see there are available devices to test out our app. You can select the one you just installed.
Now go ahead and click the run button which is a green play button beside the devices drop down.
Android Studio begins building the Bullseye app and installs it on your selected device. And 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 World.” You’ll be making the app your own. You will display your name instead.
To do this, head over to the “Project Navigator.”
Then open up the
res folder then
layout and then double click on
activity_main.xml to open it up.
Dont worry much about what this file does for now, you’ll learn more about it in the next episode. Just click on the “Code” tab to change the view.
TextView tag, you’ll find an attribute called
android:text with a value of
Update the value to say hello to yourself. I’ll go ahead and add a name like so:
Now its time to run the app.
But if you notice, the green play button has changed to a green repeat button.
This time around, hover on the button beside the run button.
The button with an
It says “Apply Changes and Restart Activity”
Clicking this doesnt quit the app and reinstall it. You use it to refresh the app when you make small changes like this.
You’ll see the difference between the two buttons as we progress in this course. Go ahead and click it.
And there you have it. The bullseye app now displays a name in the greeting text.