Can't create new Kotlin project after updating to Android Studio 4.2
I updated Android studio 4.2 but I wasn't able to create new project kotlin
A problem occurred configuring root project 'My Application'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0-release-764.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.0-release-
764/kotlin-gradle-plugin-1.5.0-release-764.pom
- https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.0-release-764/kotlin-gradle-plugin-1.5.0-release-764.pom
Required by:
project :
Possible solution:
- Declare repository providing the artifact, see the documentation at
https://docs.gradle.org/current/userguide/declaring_repositories.html
The error is clear Gradle was unable to find the library that you declared
Possible fixes
Location
Project -> build.gradle
//update it
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30"
}
Edited kotlin has released stable version of version 1.5.0 last night you can use this version to stay up-to-date
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0"
}
Worked for me:
Location: build.gradle
change
buildscript {
ext.kotlin_version = "1.5.0-release-764"
repositories {
google()
mavenCentral()
}
to
buildscript {
ext.kotlin_version = "1.5.0"
repositories {
google()
mavenCentral()
}
You should know that there are "two" build.gradle files in the Gradle Scripts on Android Studio, the build.gradle(Project) and build.gradle(Module). It took me hours to realize that I've been looking at the Module version of build.gradle while attempting to fix this and wasn't able to find the proper kotlin version variables to change.
build.gradle(Project) is the proper build.gradle you want to make changes to.
From there change
buildscript {
ext.kotlin_version = "1.5.0-release-764"
repositories {
google()
mavenCentral()
}
to
buildscript {
ext.kotlin_version = "1.5.0"
repositories {
google()
mavenCentral()
}
and try to rebuild your project again. This should work.