skip to Main Content

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!

5

Answers


  1. 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.

    Login or Signup to reply.
  2. 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!

    Login or Signup to reply.
  3. 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

    Login or Signup to reply.
  4. update android studio to the lastest version

    Login or Signup to reply.
  5. only need to del these
    androidTestImplementation ‘androidx.test.ext:junit:1.1.4’
    androidTestImplementation ‘androidx.test.espresso:espresso-core:3.5.0’

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search