解决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 //这里声明了此插件
}
相关推荐
星霜笔记8 小时前
GitMob — 手机端 GitHub 管理工具
android·kotlin·github·android jetpack
android_cai_niao11 小时前
OkHttp 使用教程:从入门到精通(Kotlin)
okhttp·kotlin
Yang-Never1 天前
OpenGL ES ->YUV图像基础知识
android·java·开发语言·kotlin·android studio
idealzouhu2 天前
【Kotlin】 数据流完全指南:冷流、热流与 Android 实战
android·开发语言·kotlin
常利兵2 天前
Android 字体字重设置:从XML到Kotlin的奇妙之旅
android·xml·kotlin
idealzouhu2 天前
【Kotlin】快速理解协程
kotlin
hnlgzb2 天前
Gemini:kotlin这几个类型有什么区别?类比java的文件,是怎样的?
java·开发语言·kotlin
hnlgzb2 天前
kotlin安卓app中,当一个类继承ViewModel类的时候,这个类是想干什么?
android·开发语言·kotlin
新镜2 天前
【Kotlin】StateFlow / MutableStateFlow只有值不相等时才会发射
kotlin
hnlgzb2 天前
kotlin类 继承android.app.Activity 和androidx.activity.ComponentActivity 有什么区别?
android·kotlin·androidx