Setting up Kotlin in Android Studio

Vatsal Bajpai
1 min readJul 29, 2016

--

Installing the Kotlin Plugin

To get started with Kotlin first we need to install Kotlin plugin provided by JetBrains. To install the Kotlin plugin you need to click on Preferences (Settings) and select the Plugins entry. Easiest way is to just start typing plugin as soon as the dialog pops up.

Click on the ‘Install JetBrains plugin…’ and select Kotlin from the list. Right-click and choose Download and Install, after that restart Android studio for the plugin to get activated.

Configuring Gradle

After the plugin installs do a new project or any existing one will also do, we still need to setup Kotlin dependencies in the Gradle configuration for our project to use Kotlin.

Open the project build.gradle and paste like this:

buildscript {  
ext.kotlin_version = '1.0.2-1'
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

Now open the app build.gradle and paste this:

apply plugin: 'kotlin-android'android { 
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
repositories {
mavenCentral()
}

Now we are set up to make our Kotlin application :)

--

--

Vatsal Bajpai

Engineer at @sliceit, Ex - @BranchMetrics | Building products for billions