How do I Create a Kotlin Project in Android Studio?
The Kotlin plugin also includes a tool that will do the Gradle configuration for us.
Just got to Tools -> Project -> Configure Kotlin in the project. Choose the latest Kotlin version, and press OK.
buildscript { ext.kotlin_version = '1.1.2-5' repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { jcenter() } }
As you can see, it is creating a variable that saves the current Kotlin version. We need that version number in several places, for instance in the new dependency that was added for the Kotlin plugin.
It will be useful again in the module build.gradle
, where the configuration has also added a dependency to the Kotlin standard library. Go check it now:
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { ... } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" }