解决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 //这里声明了此插件
}
相关推荐
hnlgzb11 小时前
目前编写安卓app的话有哪几种设计模式?
android·设计模式·kotlin·android jetpack·compose
黄林晴18 小时前
Kotlin 2.4.0 正式发布,快来看看有哪些更新
android·kotlin
Kapaseker18 小时前
Android 吐槽大会:音频焦点反人类
android·kotlin
蜡台19 小时前
Android Studio 高版本兼容低版本项目配置
android·ide·jdk·gradle·android studio
进击的cc1 天前
Android Kotlin:委托属性深度解析
android·kotlin
进击的cc1 天前
Android Kotlin:Kotlin数据类与密封类
android·kotlin
博.闻广见2 天前
19-Compose开发-LazyColumn
kotlin·composer
糖猫猫cc2 天前
Kite 实现逻辑删除
java·kotlin·orm·kite
UXbot2 天前
AI App 设计生成工具哪个好?
ui·kotlin·软件构建·产品经理·ai编程·swift
simplepeng2 天前
Kotlin 2.3 编译器:大型代码库构建速度提升 40% 以上
kotlin