What is Kotlin?
Kotlin is a statically typed programming language that runs on the Java virtual machine developed by JetBrains. At Google I/O 2017, Google has announced Kotlin an official language on Android.
1. Google announced Kotlin is an official language for android development. Kotlin is flexible and has some cool features and easy to use!
2. Kotlin is a statically-typed, modern programming language that runs on a Java Virtual Machine (JVM) by compiling Kotlin code into Java byte-code.
3. Kotlin is free and open to use.
4. It can also be compiled to JavaScript source code to native executable
5. Kotlin fully supported in Android Studio 3.0 and higher
6. Using Kotlin, you can convert existing Java code into Kotlin in very easy way and also it is easier to make new project in Kotlin.
How to setup kotlin plugin in Android Studio:
Follow the steps defined for kotlin plugin installation:
1. Go to Android Studio > File > Settings
2. Next, Settings > Plugins > Search Kotlin and click on Install plugin button.
3. When installation complete, Restart the android studio.
Follow the steps to create new Kotlin project:
Now,Let’s create a new project.
1. First, Open Android Studio -> File -> New Project
2. Choose empty activity and add project name, package name, location for project and choose minimum API level.
3. Fill all required things like application name, company domain name as shown below in sanp.
4. Now you find an option to get Kotlin support to choose Kotlin or Java Support. Checking this option will setup all kotlin dependencies and configure them into your project, you don’t require to do any hard work. Select Next.
5. Your project ready to code in Kotlin.
6. Click on Finish button.
Convert Java to Kotlin:
In your Android Studio, you can easily convert your Java files into Kotlin Files.
Currently, our Java Activity looks as below:
To convert any Java files in Kotlin, open your Java file which you want to turn into Kotlin and go to Code > Convert Java File to Kotlin File.
After converting our code to Kotlin, our activity looks as below:
Now your java file will convert into kotlin file with .kt extension and you are ready to code in kotlin.
References: (Below used ref. link to setup kotlin)
https://developer.android.com/kotlin/get-started
https://youtu.be/czKo-jPVweg
https://kotlinlang.org/