Some Kotlin libraries atached tothis project were compiled with a newer Kotlin compiler and can‘t be

问题:Some Kotlin libraries atached tothis project were compiled with a newer Kotlin compiler and can’t be

Foreword: When this problem occurred, I started to ask questions. Some people said that the kotlin version was upgraded, some said that the Android Studio version was upgraded, and some people said to delete .gradle. But in the AS, Kotlin is shown to be the latest, and there is no way to upgrade it; then I am used to using AS 4.2.2 and don’t want to upgrade; I checked the .gradle folder and found that it is several gigabytes in size, so I don’t want to cause this problem. There were other problems, so I started to explore other solutions to the problem myself.

Insert image description here

Situation description

I created a new Kotlin demo and started to report the above situation. However, it was configured one by one according to the plugin version, but this problem was prompted, and No updates found was displayed later.

Insert image description here
My kotlin version is 1.5.31, and the AS version is 4.2.2. There seems to be no problem with these.
Insert image description here
The build.gradle of other apps is as follows

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'
}

Then I thought that I would not use the relevant content of androidTest, so I deleted it and recompiled it, and the problem disappeared.
Insert image description here
Insert image description here
The app's build.gradle has deleted relevant introductions
Insert image description here

In the end, this problem was solved nonsensically. Maybe this place is just one of the reasons for the problem. If this method doesn't work, you need to make better use of Du Niang.

Insert image description here

Guess you like

Origin blog.csdn.net/tuhuanxiong/article/details/132423420