In previous article, we knew that Kotlin is more powerful language and you should try it and that’s the reason why you are here. In this article, we will learn how you can configure Android studio with Kotlin.
Start Android Studio, and create new project as below.
Android Studio 3.0
Finish the flow to create project and wait till build process complete.
For Android Studio 2.x version, you require to install plugin. You can do it by File -> Settings -> Plugin and search for “Kotlin”. Install it and restart your Android Studio.
Let’s first look at project level “gradle” file.
1) Kotlin dependency version declare. (While writing this, version is 1.1.3-2)
2) Kotlin dependency plug-in declared
Now take a lookk at module level “gradle” file.
1) Plug-ins are applied to module
2) Kotlin standard library. You can know more about it at kotlinlang.org
If you notice, when Kotlin class is created, its by default extension will be “.kt”.
1) Any implementation will be here with
: (colon) and class default constructor sign.
2) Any overrided method starts with
3) You need to write
: after object name and
? after Class to reference the declared object as Nullable.
Now, run your application.