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
4. Setup a Project in Android Studio
Leave a rating/review
To begin building the Bullseye app, you need an Integrated Development Environment known as an IDE for short. An IDE simply combines different developer tools into a single app. And Android Studio is the main IDE for building Android apps.
You’ll use this development environment to design the app and write the code for this project. And it is bundled with a lot of awesome features to aid app development like smart code completion, errors and warning higlights and some tips and actions to help refactor your code.
You first need to go to the Android Studio download page in your browser. You can get here by googling for Android Studio or using the following link in your web browser.
I’ve also added the link in the author’s notes too so you can go ahead and click it.
Click on the “Download Android Studio” button. This pops up a terms and conditions dialog. Make sure you read through it then scroll down to accept the terms and conditions.
Then select the version of android studio you want to download for your operating system. If you’re using a mac with an intel chip like core i5 or core i7 then you select the mac with intel chip. I’m on a mac book M1 pro laptop so i’ll select the one with the Apple Chip.
Then once its done downloading, open the installer and install it in the location of your choice. Most of the time, the default settings during installation works fine.
Once you’re done with the installation or when you open Android Studio for the first time, the welcome dialog is displayed. In here, you’ll see the list of projects you’ve opened recently. If this is a new installation then this tab will be empty.
To create a new Android project, click on the “New Project” button. This opens up a “New Project” window. You can create android apps for phones and tablets, Wear OS, Android TV and Automotive. We will focus on creating apps for phones in this course.
Now, this wizard gives you different starter templates to choose from. These starter templates help you create required files and folders depending on the type of application you want to create.
For example, if you want to create a map based app, you can select the Google Map Activity option. But since this is your first Android app, go ahead and select “Empty Activity.” Dont worry about what an Activity is, we’ll be covering that later in this course.
After selecting the template, click on the “Next” button.
In this section, you setup the properties for your project. First, lets give the application a name. Enter “Bullseye”.
Next is the package name which is a unique identifier for your apps. This helps us make our application unique on platforms like play store.
It makes use of a reverse domain format.
So instead of
yourcompany.com, you enter
If its a personal project, you can use
appname would be replaced with actual app’s name.
I’ll go ahead and use
com.yourcompany.bullseye for this project since this is just a demo.
Next is the save location. You can click on the folder icon on the right to browse to a specific save location on your computer. Android Studio creates an AndroidStudioProjects directory when you install it. You can save it to that directory or some other place if you want. I’ll go ahead and select a save location inside this directory.
Then we have the Language selection and Kotlin is selected by default. Android apps can be created with Java or Kotlin. This is a Kotlin course so we’ll leave it that way.
Finally, we have the Minimum SDK selection. A SDK is just a pre-built library of tools to help development.
This step is important as it determines how widely available your apps can be for the general public. API 21 which is Android 5.0 is automatically selected. And this means that your app would work on phones running on Android 5 and up.
Now you might be wondering, why can’t we just choose something higher. Click on the “Help me choose” link to learn more. From the left, you can see the Android version, the API level and then the percentage of devices running on those versions.
On the right, you can see the new features that comes with those versions. As a developer, you try to support older devices because lets face it, not everyone is gonna be using the latest android phone.
And you can see that if you select something like android 11, only over 20% of devices would be able to run your app. Now remember this is the Minimum SDK selection. This means that you can still make use of cool new features of the latest android platform and can always provide fallback options.
Okay enough of that, lets close this window. And leave the other options as it is and click on the “Finish” button.
And voila!!! Android Studio sets up the Android application. It downloads all the necessary dependencies for the application to work. This should be done withinn few seconds or minutes depending on your internet speed.
Sometimes, You’ll see a “Tip of the Day” dialog to learn tips on how to use Android studio effectively.
Now, Android Studio’s user interface can be a bit intimidating at first, but you just need to focus on two main parts at the moment:
The project navigator and the Editor.
The project navigator panel is a section of the IDE that displays the files and folders associated with the project. While the Editor is the largest open section of Android Studio.
This is where you’ll write your code and view open files.
You can see a file named
MainActivity.kt is currently open.
Dont worry about what the jargon in this file means. You’ll gain an understanding of it as you progress through this course.
We’ll be working mostly with these two views and will use other parts of the IDE when necessary.
And now we are ready to start developing Android apps with Android Studio.
But where do we run and test our app during development? Let’s talk about that in the next episode.