Here is a summary of the initial setup steps for adding Kotlin files to an Android project written entirely in Java.
+ apply plugin: 'kotlin-android'
+ apply plugin: 'kotlin-android-extensions'
buildscript {
}
repositories {
+ mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
android {
}
Apply the plugin.
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
Added maven Central to repositories
mavenCentral()
Added Kotlin jdk to the library set.
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
buildscript {
+ ext.kotlin_version = '1.3.71'
repositories {
}
dependencies {
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Add the version of Kotlin.
ext.kotlin_version = '1.3.71'
Add the classpath to dependencies.
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
You can now build Kotlin within your Java project.
Recommended Posts