解决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 //这里声明了此插件
}
相关推荐
ai2work13 小时前
ch23 综合复刻:从零做一个最小可用版本(capstone)
kotlin
ai2work14 小时前
ch21 签名、校验与发版
kotlin
JMchen15 小时前
属性动画原理与高级动画实现
android·kotlin·canvas
Android打工仔15 小时前
Kotlin 协程源码解析:协程是如何切换线程的?
android·kotlin
ai2work16 小时前
附录 D 速查索引与阅读指南
kotlin
ai2work16 小时前
ch22 诊断方法论:三个真实事故的根因分析
kotlin
Kapaseker17 小时前
你有搞明白 Volatile 什么意思吗?
android·kotlin
alexhilton1 天前
藏在设备上的秘密,终究藏不住
android·kotlin·android jetpack
ai2work1 天前
ch15 加载模型与初始化上下文
kotlin
hai_android1 天前
Kotlin / Android 常用函数使用示例手册
android·java·kotlin