How to Use Kotlin in an Existing Android App?

前端 未结 9 977
清酒与你
清酒与你 2021-01-05 03:18

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?

9条回答
  •  囚心锁ツ
    2021-01-05 04:17

    To enable Kotlin into your existing Android project. Follow these steps:-

    1. Application-level build file:- Add

      apply plugin: 'kotlin-android'

      apply plugin: 'kotlin-android-extensions'

      Add In dependency:- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    2. Project Level build File:-

      dependencies {
          classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
      

提交回复
热议问题