I have an Android App developed using Java. I now want to start using Kotlin for the same app. Is it possible to use Kotlin and Java side-by-side in an existing app?
To enable Kotlin support for your existing Java-only project follow the steps and Android Studio will automatically set-up everything for you :-
You're done and good to go!
NOTE :- Android Studio will automatically add the following lines of code for you in the respective files -
In Application-level Gradle file :-
apply plugin: 'kotlin-android'
......
dependencies{
......
implementation "androidx.core:core-ktx:+"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
......
repositories {
mavenCentral()
}
In Project-level Gradle file
buildscript {
ext.kotlin_version = '1.3.72'
......
dependencies {
......
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}