kotlin-Gradle-plugin is used to compile Kotlin code with Gradle. Its version should correspond to the Kotlin version you want to use. E.g., if you want to use Kotlin 1.0.3, you need to apply kotlin-Gradle-plugin version 1.0.3. It's good to externalize this version in Gradle. Properties (opens new window) or in ExtraPropertiesExtension.
Android Studio can configure Kotlin automatically in an Android project.
To install the Kotlin plugin, go to File > Settings > Editor > Plugins > Install JetBrains Plugin > Kotlin > Install, then restart Android Studio when prompted.
Create an Android Studio project as normal, then press Ctrl+Shift+A. Type "Configure Kotlin in Project" in the search box and press Enter.
Android Studio will alter your Gradle files to add all the necessary dependencies.
This will change the current file's extension to .kt and convert the code to Kotlin.
To convert your Java files to Kotlin files, press Ctrl+Shift+A and find "Convert Java File to Kotlin File."
These are the default paths:
|