In this tutorial, we shall learn to create an Android Application with Kotlin language support.
When we create a new Android project with Kotlin support, the Activity file shall be created with Kotlin code.
Following is a screenshot of what we shall achieve by the end of this tutorial.
Kotlin Android Application Example
For creating this example application, we used Android Studio 3.0. At the time of writing this demo application, we have Android Studio 3.0 Canary 2, which is a kind of preview version of Android Studio 3.0.
You may download the latest version of Android Studio from [https://developer.android.com/studio/].
Once you install Android Studio 3.x or higher, follow the below steps to build our first Kotlin Android Application.
Step 1: Start Android Studio
From your programs, start Android Studio application. You will get a welcome screen as shown below.
Step 2: Include Kotlin Support
Provide Application Name, Company Domain and check the option “Include Kotlin Support” and click on “Next”.
Step 3: Minimum SDK
Select the “Minimum SDK” and to continue, click on “Next”.
Step 4: Select Activity
Select “Empty Activity” and click on Next.
Step 5: Activity Name
Remain “Activity Name” as is and click on Finish. We are half-way there.
Android Studio starts building project information for “KotlinAndroidDemo”. For the first build, it may take some time.
Step 6: Install missing platform(s)
If Gradle project sync fails when the project is opened for the first time, click on the link “Install missing platform(s) and sync project” in “Messages” window the missing components are downloaded and installed by Android Studio.
Once the installing of platforn(s) is finished, Gradle sync is tried again, and this time it should be successful.
The MainActivity in the java folder is a Kotlin file and yaaay, we are using Kotlin language in our Android Application.
Step 7: Run
Run the application by connecting an Android Smart Phone to the computer in Debugging mode or with the help of emulator.
In this Kotlin Android Tutorial, we created an Android Project with Kotlin Programming Language support. In our next tutorial, we shall learn to convert Java Files to Kotiln Files in existing Android projects.