解决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 //这里声明了此插件
}
相关推荐
JMchen3 小时前
第 9 篇|网络请求基础 —— 从 HttpURLConnection 到 OkHttp
kotlin·android studio
hai_android21 小时前
Kotlin Flow combine 源码剖析:一个 Channel 如何优雅合并多条流
android·java·kotlin
敲代码的瓦龙1 天前
Jetpack?ViewModel!!!
android·开发语言·kotlin·android-studio
swithun1 天前
不用 WebView,我用 Kotlin + Compose Multiplatform 重写 Mermaid,并做了 2048 组对拍
android·开源·kotlin
JMchen1 天前
第 8 篇|本地存储技术选型 —— SP 与文件读写
kotlin·android studio
码农哈丁2 天前
从 JVM 到 Cargo:把整个 Kotlin 项目移植到 Rust 的踩坑实录
jvm·rust·kotlin
Kapaseker2 天前
写过 4000 行 ViewModel 后,我开始这样拆 Compose 页面
android·kotlin
新时代牛马3 天前
cyclictest 毛刺从哪来?从ftrace、latencytop、perf到IRQ/调度延迟定位
android·开发语言·python·kotlin
光电的一只菜鸡3 天前
为什么调整LSC会对AF产生影响
android·开发语言·kotlin
hai_android3 天前
FusibleFlow:Kotlin Flow 的融合机制原理
android·kotlin