Getting Started With Android And Kotlin

What is Kotlin?

Kotlin is a new programming language for modern multi-platform applications. It was developed by JetBrains and open source contributors. It was first appeared on 2011.

At Google I/O 2017, Kotlin was announced as an official language for Android.

How to configure Android Studio's lower version than 3.0 for Kotlin

Kotlin will bydefault be available from Android Studio 3.0. However, you can use it by configuring in lower versions too.Following steps are required to configure Android Studio for Kotlin ( I am going to illustrate it by using Window OS) -

  1. Install Kotlin plugin as below -

    Tools -> Android ->SDK Manager ->Plugins ->KotlinKotlin
  1. Restart the Android Studio and create a project.

  2. Configure Kotlin in a project,

    Tools ->Kotlin ->Configure Kotlin in Project ->Sync

    Kotlin
  1. Open Activity and convert it in Kotlin as -

    Code ->Convert java file to Kotlin

    Kotlin
  2. At last, you can see your Java files converted to kotlin like this.
    1. class Main2Activity: AppCompatActivity()   
    2. {  
    3.     override fun onCreate(savedInstanceState: Bundle ? )  
    4.     {  
    5.         super.onCreate(savedInstanceState)  
    6.         setContentView(R.layout.activity_main2)  
    7.     }  
    8. }  

Understanding the syntax of Kotlin

Kotlin

You can use controls (design in XML file) directly to Kotlin classes

Conclusion

We always like to work with the latest technologies even when we have a lack of resources. I hope this tutorial will be helpful to all who are willing to use Kotlin even when they have the lower versions of Android Studio. 

Up Next
    Ebook Download
    View all
    Learn
    View all