Android Studio 错误: 'com.android.build.gradle.LibraryExtension' is neither a plugin or a rule source and cannot be applied.
这个错误通常是由于在构建脚本中错误地应用了'LibraryExtension'插件引起的。
'LibraryExtension'是Android Gradle插件的一部分,用于配置Android库项目的构建设置。如果你想使用'LibraryExtension'插件,你应该将其添加到你的构建脚本中的'plugins'块中,而不是在'apply'语句中使用。
例如,你可以在你的构建脚本中添加以下代码:
plugins {
id 'com.android.library'
}
android {
// 配置库项目的构建设置
}
请确保在使用'LibraryExtension'插件之前,你已经正确引入了Android Gradle插件,例如:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
}
}
plugins {
id 'java-library'
}
如果你仍然遇到相同的错误,请检查你的构建脚本中是否有其他错误,并确保你使用的插件版本与你的Gradle版本兼容。
原文地址: http://www.cveoy.top/t/topic/4sX 著作权归作者所有。请勿转载和采集!