Some Kotlin libraries attached to this project were read by a newer Kotlin compiler and can't be read. Please update Kotlin Plugin
Asked Answered
K

6

8

I am facing an error:

Some Kotlin libraries attached to this project were read by a newer Kotlin compiler and can't be read. Please update Kotlin Plugin

I just created an application and started facing this error: enter image description here

The Kotlin plugin shows the following:

enter image description here

I tried to change ext.kotlin_version: enter image description here

My build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.4.32"
    repositories {
        google()
        jcenter()
    }
    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
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

My build.gradle(app):

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdkVersion 31
    buildToolsVersion '30.0.1'

    defaultConfig {
        applicationId "com.yousufjamil.myj"
        minSdkVersion 16
        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.8.0'
    implementation 'androidx.appcompat:appcompat:1.4.2'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

I would appreciate any help. Thank You!

Kedron answered 8/6, 2022 at 19:35 Comment(0)
P
3

You need to update almost everything, I believe.

currently for Gradle we have com.android.tools.build:gradle:7.2.1

coming to Kotlin, the current version is 1.6.21

repository jcenter() is deprecated and has been replaced by mavenCentral()

If you try to use jcenter() it will give a warning

JCenter Maven repository is no longer receiving updates: newer library versions may be available elsewhere

Also, check if there are any updates available for Android Studio.

Proteus answered 8/6, 2022 at 19:46 Comment(3)
Thanks for your reply. I tried doing your steps and it showed: Minimum supported Gradle version is 7.3.3. Current version is 6.5.Kedron
I have tried to fix it but it shows that I will need to install a newer version of Android Studio. By the way, thanks for your help.Kedron
In my case, I've tried everything, and the final solution is to upgrade to the latest version.Albert
T
6

Earlier I had the same error on Android Studio. If by changing the kotlin-version and gradle-version in the build.gradle file does not fixes the error. It might be because you have an older version and need to update the Android Studio [File -> Settings -> Appearance & Behavior -> System Settings -> Updates -> ' then Change to the latest stable version']. Later during the installation process, you would see the option to upgrade the gradle where you can choose the latest version. It worked for me. Hope it helps!

Topfull answered 7/9, 2022 at 16:8 Comment(1)
Thanks for your response. I have already solved the problem by updating android studio.Kedron
P
3

You need to update almost everything, I believe.

currently for Gradle we have com.android.tools.build:gradle:7.2.1

coming to Kotlin, the current version is 1.6.21

repository jcenter() is deprecated and has been replaced by mavenCentral()

If you try to use jcenter() it will give a warning

JCenter Maven repository is no longer receiving updates: newer library versions may be available elsewhere

Also, check if there are any updates available for Android Studio.

Proteus answered 8/6, 2022 at 19:46 Comment(3)
Thanks for your reply. I tried doing your steps and it showed: Minimum supported Gradle version is 7.3.3. Current version is 6.5.Kedron
I have tried to fix it but it shows that I will need to install a newer version of Android Studio. By the way, thanks for your help.Kedron
In my case, I've tried everything, and the final solution is to upgrade to the latest version.Albert
P
2

1- update the android studio by clicking the tab named help and then click "check for update" and then let the android studio be updated. 2 - restart the android studio if the error is resolved then it's well and good if not, then click on the tab "New", click on "New project" and then select project, and check the box highlighted here in the below picture. click here to see the image

this worked for me

Prudi answered 28/10, 2022 at 5:53 Comment(1)
I've already worked out the solution, but still thanks.Kedron
G
2

update android studio to the lastest version

Gabbro answered 16/11, 2022 at 11:28 Comment(0)
H
0

only need to del these androidTestImplementation 'androidx.test.ext:junit:1.1.4' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'

Heedless answered 22/11, 2022 at 12:22 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Yuki
F
0

In your build.gradle file under dependencies, try changing this:

implementation 'com.google.android.material:material:1.6.1'

to

implementation 'com.google.android.material:material:1.5.0'

This worked for me.

Felafel answered 19/8, 2024 at 11:4 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.