解决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 //这里声明了此插件
}
相关推荐
hai_android31 分钟前
从零实现一个支持跨进程(IPC)的自定义 Toast
android·kotlin·android jetpack
熊猫钓鱼>_>1 小时前
Kotlin Multiplatform for OpenHarmony 实战:kotlinx-coroutines 结构化并发适配
开发语言·kotlin·agent·harmonyos·openharmony·适配·华为云码道
熊猫钓鱼>_>3 小时前
Kotlin Multiplatform for OpenHarmony 实战:kotlinx-serialization JSON 适配
开发语言·华为·kotlin·华为云·json·harmonyos·code
倚楼听风语17 小时前
Kotlin 协程与 suspend 原理详解
java·算法·kotlin
事圆则缓1 天前
Kotlin 集合与序列:给页面一份清楚的数据
开发语言·windows·kotlin
事圆则缓1 天前
Kotlin 异步与并发:从一次搜索请求走到状态流
android·开发语言·kotlin
事圆则缓1 天前
Kotlin学习导航:从知识树走到项目与面试
android·开发语言·kotlin
mmsx2 天前
Android 插件化架构:40 个 Gradle 模块的拆分、通信与共存
android·kotlin
mmsx2 天前
Android 不改一行源码:用 AspectJ 做三类拦截
android·kotlin
熊猫钓鱼>_>2 天前
开源鸿蒙平台 KMP 三方库 kotlin-csv 适配全流程:从编码假设到沙箱真机互通验证
开发语言·人工智能·华为·kotlin·harmonyos·鸿蒙