解决Error resolving plugin xxx

问题信息

复制代码
Error resolving plugin [id: 'com.android.library', version: '8.6.0']
> The request for this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so compatibility cannot be checked.

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

* Exception is:
org.gradle.api.GradleException: Error resolving plugin [id: 'com.android.library', version: '8.6.0']
    at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.resolvePluginRequest(DefaultPluginRequestApplicator.java:188)
    at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugins(DefaultPluginRequestApplicator.java:97)
    at org.gradle.kotlin.dsl.provider.PluginRequestsHandler.handle(PluginRequestsHandler.kt:45)
    at org.gradle.kotlin.dsl.provider.StandardKotlinScriptEvaluator$InterpreterHost.applyPluginsTo(KotlinScriptEvaluator.kt:212)
    at org.gradle.kotlin.dsl.execution.Interpreter$ProgramHost.applyPluginsTo(Interpreter.kt:385)
    at Program.execute(Unknown Source)

问题原因

在module中使用了未在项目根目录下build.gradle中声明的插件,比如这里的'com.android.library'插件。

解决方法

在项目根目录下的build.gradle中声明此插件即可,如下:

Kotlin 复制代码
plugins {
    alias(libs.plugins.android.application) apply false
    alias(libs.plugins.kotlin.android) apply false
    alias(libs.plugins.jetbrains.kotlin.jvm) apply false
    alias(libs.plugins.android.library) apply false //这里声明了此插件
}
相关推荐
没有bug.的程序员8 小时前
依赖治理之巅:Maven 与 Gradle 依赖树分析内核、冲突判定博弈与工程自愈实战指南
java·gradle·maven·依赖治理·冲突判定·依赖树
zh_xuan9 小时前
kotlin with函数
开发语言·kotlin
zh_xuan9 小时前
kotlin let函数
开发语言·kotlin
Kapaseker9 小时前
Kotlin 协程的取消,我觉得设计的不好
android·kotlin
zh_xuan9 小时前
kotlin 作用域函数run
开发语言·kotlin
Libraeking9 小时前
04 跨越边界:如何将 Android 本地能力暴露给 AI(MCP + Kotlin)
android·人工智能·kotlin
zh_xuan9 小时前
kotlin 作用域函数also
开发语言·kotlin
zh_xuan10 小时前
kotlin 作用域函数apply
开发语言·kotlin·作用域函数
DeepModel1 天前
【回归算法】决策树回归超详细讲解
决策树·回归·kotlin
zh_xuan1 天前
kotlin Flow的用法2
android·开发语言·kotlin·协程·flow·被压