问题:Some Kotlin libraries atached tothis project were compiled with a newer Kotlin compiler and can’t be
前言:出现这个问题的时候,就开始度娘,有人说kotlin版本升级,有人说Android Studio版本升级,也有人说删除.gradle。但是在AS里面Kotlin显示已经是最新了,没办法升级了;然后自己使用4.2.2的AS已经习惯了不想升级;查看了.gradle的文件夹,发现几G之多,就不想因为这个问题导致其他的问题,所以就开始自己摸索该问题的其他解决方式。
情况描述
新建了一个Kotlin的demo,就开始报上面的情况,但是根据plugin版本都一一配置好了,但就是提示这个问题,后面也是显示No updates found。
我的kotlin版本是1.5.31,AS版本是4.2.2,这些看起来都没啥问题
其他app的build.gradle如下
android {
compileSdkVersion 30
defaultConfig {
applicationId "com.demo.kotlindemo"
minSdkVersion 27
targetSdkVersion 30
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.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
接着我想着androidTest的相关内容我用不到,反手给他删了,重新编译,该问题就没了。
app的build.gradle删除了相关引入