Creating First Project In Android Studio Using Kotlin Programming Language

Greetings!
We have recently published 100+ articles on android tutorials with kotlin and java. If you need, you may visit Android Tutorial for beginners page. You can also check Kotlin Tutorial for beginners. Also, if you are interested in content writing, you can mail us at tutorialwing@gmail.com.

In this tutorial, you will learn about creating first project in android studio using Kotlin programming language.
Kotlin plugin is bundled with Android Studio starting from version 3.0. If you are using previous version, you would need to do some setup to develop application in Kotlin programming language.

Install Kotlin plugin in Android Studio for version before 3.0

We will first go through the process for Mac User, then, we will cover the process for Windows User.

Steps to Install Kotlin plugin for Mac User

If you are using Mac, Follow Steps below –
a. Click on the Android Studio (Shown at top-left) => Preferences… .
b. Then, Select Plugins and click on Install JetBrains plugin.
c. Now, Search for Kotlin plugin.
d. Click on the Install button appearing on the right side.
e. After successfully installing Kotlin plugin, restart the IDE.

Or

Currently, if you are at Welcome to Android Studio screen, you would need to follow below steps to install the Kotlin plugin.
a. Click on Configure (Shown at bottom-right) button.
b. Then, click on the Plugins => Install JetBrains plugin link.
c. After that, search for Kotlin plugin and click on the Install link appearing on the right box of the screen.
d. Then, wait till the plugin is installed successfully.
e. Restart the IDE once plugin is installed successfully.

Steps to Install Kotlin plugin for Windows User

If you are using Windows, Follow Steps below –
a. Click on the File (Shown at top-left) => Settings… .
b. Then,Select Plugins and click on Install JetBrains plugin.
c. Now, Search for Kotlin plugin.
d. Click on the Install button appearing on the right side.
e. After successfully installing Kotlin plugin, restart the IDE.

Or

Currently, if you are at Welcome to Android Studio screen, you would need to follow below steps to install the Kotlin plugin.
a. Click on Configure (Shown at bottom-right) button.
b. Then, click on the Plugins => Install JetBrains plugin link.
c. After that, search for Kotlin plugin and click on the Install link appearing on the right box of the screen.
d. Then, wait till the plugin is installed successfully.
e. Restart the IDE once plugin is installed successfully.

Since we have successfully installed Kotlin plugin in our Android Studio IDE, we will proceed further to create first application using kotlin programming language.

Now, There are 2 conditions. First condition is you are using Android Studio 3.0 or above. Second condition is you are using Android Studio below version 3.0.

We will cover both conditions. At first, We will cover creating first project in android studio below version 3.0




Creating First Project in Android Studio Below Version 3.0

You can go through Creating New Project tutorial to create your first project in android studio below version 3.0. Here, I have covered the steps in detail. However, I am also mentioning the steps, in brief, in this tutorial.

Follow steps below to create a new project –
1. if you are at Welcome to Android Studio screen, select Start a new Android Studio Project.

Tutorialwing - Android Studio New Project Step-1

Tutorialwing – Android Studio New Project Step-1

2. you will be redirected to the new screen.

Tutorialwing - Android Studio New Project Step-2

Tutorialwing – Android Studio New Project Step-2


Add the necessary details and click next .

3. Then, select target devices and click next.

Tutorialwing - Android Studio New Project Step-3

Tutorialwing – Android Studio New Project Step-3

4. Selecting Empty Activity and click next.

Tutorialwing - Android Studio New Project Step-4

Tutorialwing – Android Studio New Project Step-4

5. Then, Enter required detail and click on finish.

Tutorialwing - Android Studio New Project Step-5

Tutorialwing – Android Studio New Project Step-5

6. You will see screen as below.

Tutorialwing - Android Studio New Project Step-6

Tutorialwing – Android Studio New Project Step-6

That’s it. Your project is successfully created.

Now, you need to convert Java code to Kotlin and configure Kotlin in the project.

Convert Java Code to Kotlin

Open MainActivity.java file and invoke action Convert Java File to Kotlin File. There are several ways to do it.
a. Easiest way is to invoke Find Action. Type Shift + Command + A. Then, Type Action name in it. So, type Convert Java File to Kotlin File. Select the option shown.

Tutorialwing - Android Kotlin tutorial

Press Shift + Command + A to get this

b. Go to Code => Convert Java File to Kotlin File. Select this option.

Tutorialwing - Android Kotlin Tutorial

Go to Code => Convert Java File to Kotlin File

After the conversion, you will have an activity written in Kotlin as below –

MainActivity Written In Kotlin Language

MainActivity Written In Kotlin Language

Configure Kotlin in the Project

Follow steps below to configure kotlin in project –

1. If Kotlin is not configured in the project, you will see a message to configure it when you start editing kotlin file.

Configure Kotlin In the Project

Configure Kotlin In the Project

However, you can invoke the configuration as below.
a. Go to Tools => Kotlin => Configure Kotlin In Project. Click on it.

Configure Kotlin In Project

Configure Kotlin In Project

2. Now, you are then prompted for the version of Kotlin. Select version and press OK.

Choose Kotlin Version to Configure

Choose Kotlin Version to Configure

3. Finally, Sync the Project.

Sync Project

Sync Project

That’s it. You are done with creating First project in android studio using Kotlin in version below 3.0. You can run the project and see the output. Now, we will create first project in android studio using kotlin in version 3.0 or above.




Creating First Project in Android Studio – Version 3.0 or Above

Since Kotlin plugin is bundled with Android Studio starting from 3.0, you do not need to do above steps. You just create new project as mentioned below and run the application. That’s it.

Follow steps below to create a new project –
1. if you are at Welcome to Android Studio screen, select Start a new Android Studio Project.

Create New Project using Android Studio 3.0

Create New Project using Android Studio 3.0

2. you will be redirected to the new screen.

Include Kotlin Support In Project

Include Kotlin Support In Project

Note: Do not Forget to Select Include Kotlin Support. Otherwise Your project will be created in Java language.
Add the necessary details and click next.

3. Then, select target devices and click next.

Select Target Devices in Android Project

Select Target Devices in Android Project

4. Selecting Empty Activity and click next.

Select An Activity While creating Application

Select An Activity While creating Application

5. Then, Enter required detail and click on finish.

Create kotlin and xml file

Create kotlin and xml file

That’s it. You have successfully created first project in android studio using kotlin programming language. Now, run it on the emulator and see the output. This works exactly same as Java. You can create release apk same as what you do for any application written in Java. Kotlin compiler produces byte-code, thus there really is no difference in terms of look and feel of Kotlin applications versus those written in Java.

Support Us

If you like Tutorialwing and would like to contribute, you can email an article on any educational topic at tutorialwing@gmail.com. We would love to publish your article. See your article on Tutorialwing and help others with your knowledge. Follow Facebook, LinkedIn, Google+, Twitter, Youtube for latest updates.
Greetings!
We have recently published 100+ articles on android tutorials with kotlin and java. If you need, you may visit Android Tutorial for beginners page. You can also check Kotlin Tutorial for beginners