Hello I tried to run Kotlin file on Android Studio (version 4.1) and I got an error: Kotlin library {0} was compiled with a newer Kotlin compiler and can t be read. Please update Kotlin plugin.
Even I got this error I m able to run kotlin files but Ide don t gives me tips when I use kotlin functions and methods are marked by red colour. Kotlin version in gradle is 1.6.0, if I m return to older version I can see tips about method names and red colour is not showed. Gradle build(app):
plugins {
id com.android.application
id kotlin-android
}
android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.kotlin_udemy4"
minSdkVersion 26
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile( proguard-android-optimize.txt ), proguard-rules.pro
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = 1.8
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation androidx.core:core-ktx:1.7.0
implementation androidx.appcompat:appcompat:1.4.2
implementation com.google.android.material:material:1.6.1
testImplementation junit:junit:4.+
androidTestImplementation androidx.test.ext:junit:1.1.3
androidTestImplementation androidx.test.espresso:espresso-core:3.4.0
}
逐步建设:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.6.0"
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.0"
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
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
是否有任何人知道如何解决这一问题?