When you create a new android project, generally you used java programming language. From past year many programming language has been introduced, now google approves Kotlin – is a new programming language from JetBrains. Kotlin is a statically-typed programming language that runs on the JVM. It can also be compiled to JavaScript source code.That means developers can use the Java Libraries they already use now, and the code they write with Kotlin can also be converted to Java and vice versa.
Kotlin has some amazingly features!
Kotlin is fully supported in Android Studio 3.0, so it’s easy to create new projects with Kotlin files, add Kotlin files to your existing project, and convert Java language code to Kotlin.
When you are going to create a android project with kotlin, first time android studio don’t know what to do with kotlin so first of all you have to install the Kotlin plugin and configure Kotlin in your project.
Steps to install Kotlin Plugins:
Go to File → Settings → Plugins → Install JetBrains plugin… and then search for and install Kotlin. If you are looking at the “Welcome to Android Studio” screen, choose Configure → Plugins → Install JetBrains plugin… You’ll need to restart the IDE after this completes.
Steps to install Kotlin Plugins:
Go to File → Settings → Plugins → Install JetBrains plugin… and then search for and install Kotlin. If you are looking at the “Welcome to Android Studio” screen, choose Configure → Plugins → Install JetBrains plugin… You’ll need to restart the IDE after this completes.
Steps to create new project using Kotlin:
In Android Studio, first create a new project click on File → New → New Project. Or if you’ve just opened Android Studio and see the Welcome to Android Studio window, click Start a new Android Studio project.
The following window appears through the process of new project creation. You need to name the project and choose which Android SDK version you have installed.
Check Include Kotlin support.
Click on Next button.
5) Choose the Android version:
6) Choose activity to mobile:
7) Name the activity:
In Android Studio 3.0, you can choose to create the activity in Kotlin right away, so you can skip the “Converting Java code to Kotlin” step. Earlier versions will create an activity in Java, and you can use the automated converter tool to convert it.
Add Kotlin to an existing project
If you want to add Kotlin code to an existing project, simply click File > New and select one of the various Android templates. If you don’t see the list of templates in this menu, first open the Project window and select your app module.
Then click on finish, and you’re done.
You are now ready to build the application and run it on device.
For video tutorial visit Codekul’s youtube channel – Youtube/Codekul