MYJ World
MYJ World

Reputation: 950

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

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!

Upvotes: 8

Views: 22497

Answers (6)

Pedro L'San.
Pedro L'San.

Reputation: 1

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.

Upvotes: 0

钟子敬
钟子敬

Reputation: 1

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

Upvotes: 0

Norman Daniel Vicente
Norman Daniel Vicente

Reputation: 73

update android studio to the lastest version

Upvotes: 2

Nikhil Sachsn
Nikhil Sachsn

Reputation: 23

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

Upvotes: 2

Kamal Boruah
Kamal Boruah

Reputation: 69

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!

Upvotes: 6

Dr. Sa.M.
Dr. Sa.M.

Reputation: 2513

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.

Upvotes: 3

Related Questions