简体   繁体   中英

Android Studio 4.2 Kotlin Plugin Issue

Cannot build a new project using Android Studio 4.2 because of the following error:

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

When I changed the Kotlin plugin version from ext.kotlin_version = "1.5.0-release-764" to ext.kotlin_version = "1.5.0" app builds successfully but the following warning appears:

Kotlin version that is used for building with Gradle (1.5.0) differs from the one bundled into the IDE plugin (1.5.0-release-764) 

在此处输入图像描述

Change From

buildscript {
ext.kotlin_version = "1.5.0-release-764"
......}

Change To

buildscript {
ext.kotlin_version = "1.5.0"
....}

Change the Kotlin Version Issue will be cleared.

This is a known bug:

https://youtrack.jetbrains.com/issue/KTIJ-11590

"the problem will be fixed in 1.5.10 update"

I went to the build.gradle file and changed the ext.kotlin_version = "1.5.0" to ext.kotlin_version = "1.4.32" , as that was the version of an older project which successfully built.

I was using the same version of kotlin-gradle-plugin bundled with the IDE, which is 1.5.10, in Android studio 4.2.1, and for me disabling the 'Block connections to untrusted servers' in my anti-virus fixed the error.

According to Android Studio's message, Kotlin's latest stable version is 1.5.0-release-764 . If you want to (or in this case I guess everyone needs to) use version 1.5.0 :

  1. Go to Tools in the menu

  2. Go to Kotlin

  3. Choose Configure Kotlin Plugin Updates

  4. In the drop-down, choose the early access preview version of 1.5.x and then click OK.

Gradle sync will now configure the Studio with Kotlin 1.5.0 .

在此处输入图像描述

if you work on flutter project,you just need to update flutter sdk run that command in terminal:

flutter upgrade

After updating, new flutter version will fix that errors automatically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM