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) -
- Install Kotlin plugin as below -
Tools -> Android ->SDK Manager ->Plugins ->Kotlin
- Restart the Android Studio and create a project.
- Configure Kotlin in a project,
Tools ->Kotlin ->Configure Kotlin in Project ->Sync
- Open Activity and convert it in Kotlin as -
Code ->Convert java file to Kotlin
- At last, you can see your Java files converted to kotlin like this.
- class Main2Activity: AppCompatActivity()
- {
- override fun onCreate(savedInstanceState: Bundle ? )
- {
- super.onCreate(savedInstanceState)
- setContentView(R.layout.activity_main2)
- }
- }
Understanding the syntax of 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.