解决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 //这里声明了此插件
}
相关推荐
唐青枫12 小时前
Kotlin Context Parameters 详解:别再把 Logger、事务和配置层层往下传
kotlin
Coffeeee13 小时前
如何使用Glide和Coil加载WebP动图
android·kotlin·glide
Kapaseker14 小时前
5 分钟搞懂 Kotlin DSL
android·kotlin
alexhilton1 天前
使用Android Archive进行打包
android·kotlin·android jetpack
逐光老顽童4 天前
Java 与 Kotlin 混合开发避坑指南:30 个真实案例实录
android·kotlin
plainGeekDev4 天前
null 判断 → Kotlin 可空类型
android·java·kotlin
plainGeekDev4 天前
getter/setter → Kotlin 属性
android·java·kotlin
Junerver5 天前
我写了一个 Compose Multiplatform 组件库,你可能会用到
kotlin·android jetpack
Ehtan_Zheng5 天前
Kotlin const val vs val:字节码、性能与隐藏陷阱详解
android·kotlin
zhangphil6 天前
大日志文件截取,从指定日志文件中提取两个标记字符串之间的全部内容,Kotlin
kotlin