解决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 //这里声明了此插件
}
相关推荐
赏金术士4 小时前
Jetpack Compose 状态提升(State Hoisting)完全指南
android·kotlin·compose
Hali_Botebie6 小时前
岭回归(Ridge Regression),也称为L2正则化回归
数据挖掘·回归·kotlin
萌新杰少8 小时前
安卓原生项目迁移KMP——核心迁移
android·kotlin·jetbrains
Kapaseker10 小时前
Kotlin 的 SAM 到底解决了什么?
kotlin
plainGeekDev1 天前
Android 开发者再不转Kotlin,真的来不及了
android·kotlin
赏金术士1 天前
第五章:数据层—网络请求与Repository
android·kotlin·compose
plainGeekDev1 天前
Android 专家岗 Kotlin 面试题:能答出这些,说明你对语言设计有自己的理解
android·kotlin
plainGeekDev1 天前
Android 资深岗 Kotlin 面试题:只会用协程不够,你得懂它为什么这么设计
android·kotlin
陈皮糖_1 天前
Kotlin 设计哲学:写给Java开发者的思维转变指南
kotlin
赏金术士1 天前
第二章:Compose入门—声明式UI编程
android·ui·kotlin·compose