解决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 //这里声明了此插件
}
相关推荐
idingzhi3 小时前
A股量化策略日报(2026年05月22日)
android·开发语言·python·kotlin
赏金术士4 小时前
Android 动画对比指南:View 系统 vs Jetpack Compose
android·kotlin·compose
plainGeekDev6 小时前
Kotlin核心:空安全都搞不明白,还敢说熟练Kotlin?
android·面试·kotlin
jzlhll1237 小时前
Kotlin 协程高级用法之 NonCancellable
android·开发语言·kotlin
JohnnyDeng949 小时前
Paging 3 分页加载架构全解析:从数据源到 UI 的完整链路
android·ui·kotlin
高林雨露10 小时前
kotlin 相关code
开发语言·kotlin
huaCodeA11 小时前
Android面试-Kotlin作用域函数
android·面试·kotlin
QING6181 天前
Kotlin inline 实战详解 —— 新手须知
android·kotlin·android jetpack
Ehtan_Zheng1 天前
Kotlin Flow:combine()、merge() 和 zip() 的区别 —— 不要再互相替代使用
kotlin
高林雨露1 天前
Java 转 Kotlin 对照开发指南
java·开发语言·kotlin