After learning about Kotlin Architecture & Installing Android Studio in previous tutorials, now we are ready to build our first Android App in Kotlin. Follow the tutorial to the end to develop your first Android App in Android Studio.
1. Start a New Android Studio Project
If you have not yet installed Android Studio you can follow our previous tutorial to successfully Install Android Studio. Now launch the Android Studio & you will see the following window.
Click on “Start a new Android Studio Project”.
2. Choose Project Template
The next step is to choose a project template. In Android Studio we have many project templates which we can use to avoid writing boilerplate codes. For example, we are intended to use Google Maps, we can choose Google Map Activity. That will automatically add a default activity with Google Map configurations. But in this first project, we will be using Empty Activity. It will create a default Activity but with minimum code. Here you can read more about project templates in the official documentation.
Choose “Empty Activity” and Click “Next”.
3. Add Project Details
Now in the next window Android Studio will ask about our project details, like Project Name, Package Name, Location, Language, and Min SDK version. The screenshot & details about all these terms are the following.
(i) Project Name
Add the Name of your App here.
(ii) Package Name
Package Name is the unique identifier of your App on the Google Playstore. Usually, we set it in the following format. It’s also known as Application ID.
(iii) Project Location
Choose your project folder location in your computer.
(iv) Project Language
In Android Studio we can develop Android App either using Kotlin or Java, as both are supported. Even we can use both in a single project. But as we are writing this tutorial for Kotlin, so choose Kotlin from the Language Dropdown.
(v) Minimum SDK Version
Here we can set the Minimum SDK version on which our App will support. Right now in the above screenshot, you can see its API level 16 (Android 4.1 Jelly Bean). So it means that those users having an Android version less than 4.1 will not be able to install the App. Although 99.8% of the Android users are having Android version 4.1 or above. We can use less SDK version but then we may not use the latest SDK features in our project which are introduced after Android 4.1. Here you can read more about Target SDK Version in the official documentation.
(vi) Uncheck Use Legacy Android Support Libraries Option
Android provides Support libraries to use the latest SDK features in Older Android versions to eradicate the problem discussed in point (v). Previously it provides Support Libraries v4 & v7. But now it provides Androidx, the latest one. So uncheck this option to use the latest Androidx and not to use legacy support libraries.
Click Finish to successfully build your first Android App in Kotlin. Android Studio will open your first Android Project to let you start development.
If you have any questions feel free to ask in the comments section below.