1、打开项目的build.gradle,补充添加kotlin的版本号声明
buildscript {
ext.kotlin_version = '1.4.31'
repositories {
google()
//jcenter()
maven{ url'http://maven.aliyun.com/nexus/content/groups/public/' }
maven{ url'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
maven { url 'https://jitpack.io' }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
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
classpath 'com.github.canwen2003:module_plugin:v1.0.0.0'
}
}
2、打开模块的build.gradle,在文件开头补充添加Kotlin的扩展插件
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
接着在dependencies节点下补充添加Kotlin插件的编译说明:
//Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"