org.gradle.api.plugins.UnknownPluginException:插件[id:“org.jetbrains.kotlin.android”,版本:“1.6.21”,适用于:错误]

fcwjkofz  于 2022-12-29  发布在  Kotlin
关注(0)|答案(2)|浏览(2280)

嘿,我刚刚在android studio中创建了一个新项目。我遇到了这个奇怪的问题。有人知道为什么这会出错吗?

    • 错误**
Build file '/Users/vmodi/AndroidStudioProjects/KtorApplication/build.gradle' line: 5

Plugin [id: 'org.jetbrains.kotlin.android', version: '1.6.21', apply: false] was not found in any of the following sources:

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'org.jetbrains.kotlin.android', version: '1.6.21', apply: false] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.jetbrains.kotlin.android:org.jetbrains.kotlin.android.gradle.plugin:1.6.21')
  Searched in the following repositories:
    Gradle Central Plugin Repository
    Google
    MavenRepo
    at ...
    • 构建.分级. kts**
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.1.3' apply false
    id 'com.android.library' version '7.1.3' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我正在使用最新的大黄蜂Android Studio 。谢谢

x7yiwoj4

x7yiwoj41#

在build.gradle.kts中使用id("kotlinx-serialization")(模块:app)

cig3rfwq

cig3rfwq2#

确保settings.gradle文件包含您应该拥有的所有插件存储库:

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}

此外,您可能需要降级Kotlin版本或升级gradle版本,这两个版本之间有一个兼容性列表。
https://docs.gradle.org/current/userguide/compatibility.html

相关问题