1.第一步先在工程目录的build.gradle 添加这两行
buildscript { ext { kotlin_version = '1.5.21' } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } }
2.第二步在build.gradle(app)
头部加入
apply plugin: 'kotlin-android'
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}