解决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 //这里声明了此插件
}
相关推荐
mmsx10 小时前
Android 防二次打包第一道锁:签名校验与完整性校验
android·kotlin
mmsx10 小时前
Android 混淆不等于安全:二次打包链路完整走一遍
android·kotlin
墨天梦14 小时前
D05_ViewModel与单向数据流
android·kotlin
墨天梦17 小时前
D03_Compose列表与稳定身份
android·gitee·kotlin
萌新杰少18 小时前
Kuikly股票查看软件开发体验——SaiRen
android·kotlin·客户端
用户928172673901618 小时前
Android Compose版本的AI组件库来了。
android·kotlin
墨天梦1 天前
B19_SunnyWeather到阅读客户端
android·kotlin
墨天梦2 天前
B17_LifecycleLiveData与Flow
android·kotlin
熊猫钓鱼>_>3 天前
Kotlin Multiplatform for OpenHarmony 实战:为 Landscapist 实现图片加载适配
开发语言·kotlin·华为云·ai编程·harmonyos·鸿蒙·openharmony
ZealSinger3 天前
Kotlin2.4迁移context parameters
kotlin·协程·迁移·kotlin2.4