解决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 //这里声明了此插件
}
相关推荐
绿色水杯0071 天前
Android Gradle 依赖分析器
gradle
plainGeekDev1 天前
Glide 该换了?Coil:Kotlin 时代的图片加载库
android·开源·kotlin
plainGeekDev1 天前
Android内存面试题:OOM都解决不了,性能优化从何谈起?
android·面试·kotlin
疏狂难除1 天前
JetBrains IDE插件开发教程(二)——学习初始代码
ide·kotlin
plainGeekDev1 天前
Kotlin协程面试题:suspend原理都说不清,协程你真会用?
android·面试·kotlin
赏金术士2 天前
第六章:UI组件与Material3主题
android·ui·kotlin·compose
赏金术士2 天前
Jetpack Compose 底部导航实战教程(完整版)
android·kotlin·compose
Honker_yhw3 天前
大数据管理与应用系列丛书《数据挖掘》(吕欣等著)读书笔记-LASSO回归
数据挖掘·回归·kotlin
程序员煊子3 天前
用 Cursor 从零搭一个 Compose 本地记账 App:实战记录与源码解析
android·kotlin·compose·cursor
alexhilton3 天前
面向Android开发者的Google I/O 2026
android·kotlin·android jetpack