Kotlin is a type of statically typed programming language for multiple platforms and runs on JVM ( Java Virtual Machine ). Kotlin is developed by IntelliJ IDEA. IntelliJ IDEA also developed the Android Studio IDE. Kotlin is now officially available on Android Studio 3.0 version, But if you have a older version of Studio then you need to install its official plugin. After installing the Kotlin plugin you can easily build android apps using Kotlin language in Android Studio.
Benefits of Using Kotlin :
- Small code writing.
- Easily understandable code.
- Faster code compilation and code execution that increase the app performance.
- Kotlin libraries for extra functionality.
How to Install And Configure Kotlin Plugin in Android Studio.
1. Start a new project in Android Studio.
2. After creating new project, Click on File -> Settings.
3. Click on Plugins . Now search for Jetbrains . Tick on EditorConfig, Click on OK button . It will show us all plugins available in Jetbrains.
4. Now select Kotlin and click on Install button.
5. Here you go after clicking on Install button the official Kotlin plugin should start downloading.
6. After installing the plugin it would say to Restart the Android Studio.
Here you go now Kotlin is successfully installed and ready to use in your Studio project. Now Next step is to convert your JAVA file code into Kotlin code .
How to Change convert MainActivity.java file code into Kotlin .kt :
1. Open your project’s MainActivity.java file.
2. Press CTRL + SHIFT + A to display Find Action Window. The window should look like below screenshot.
3. Type Convert Java File to Kotlin File in this window and select Convert Java File to Kotlin.
4. Now you should see a dialog box says ” Converting Java to Kotlin “.
Here you go not your MainActivity.java file should successfully converted into MainActivity.kt file.
Below is the screenshot of MainActivity.kt file after converting.
5. Now when you start editing this file according to your needs then you can show a message that ” Kotlin is not configured “. Click on Configured link.
6. Select the latest Kotlin compiler and runtime version and hit the OK button.
7. Now it will add all the libraries . Hit the Sync Now link.
Here you go not the Kotlin programming language is successfully configured in your Studio environment 🙂 Enjoy coding. Feel free to comment .