Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21

Question

Asked by Pannam T on November 12, 2021 (source).

After reinstalling android studio and vscode I am running into issues with kotlin and gradle. The changes I have made is in root of android folder under build.gradle.

buildscript {
    ext.kotlin_version = '1.5.21 ' //previous was 1.5.20
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.2' // previous was 4.1.1
        classpath 'com.google.gms:google-services:4.3.8'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

I haven't made any other changes, How can I fix this ? The error I get is

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21 .
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.21 /kotlin-gradle-plugin-1.5.21 .pom
       - https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.21 /kotlin-gradle-plugin-1.5.21 .pom
     Required by:
         project :


Answer

Question answered by JustInCoding (source).

The problem you're facing is occurring because you have not added mavenCentral() to your repositories {} block. Add it like this:

repositories {
  mavenCentral()
  google()
}

And also, remove jcenter(), it is deprecated now.

FLUTTER KOTLIN VISUAL-STUDIO-CODE
SHARE: