android - 无法应用插件 [class 'org.gradle.language.base.plugins.LifecycleBasePlugin']
问题描述
我只是在 android studio 上打开一个旧项目,当我尝试在模拟器上运行应用程序时,我看到了这个错误
Build file 'D:\Courses\Java\Android Projects\CustomListViewExample\app\build.gradle' line: 1
A problem occurred evaluating project ':app'.
> Failed to apply plugin [class 'org.gradle.language.base.plugins.LifecycleBasePlugin']
> Cannot add task 'clean' as a task with that name already exists.
我试图删除第一行,但出现了新错误
A problem occurred evaluating project ':app'.
> Could not find method android() for arguments [build_epi4gcthpuruce7js1p17xxvs$_run_closure1@5c2243f6] on project ':app' of type org.gradle.api.Project.
这是完整的build.gradle(app)文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.example.nh.customlistviewexample"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.13.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
}
build.gradle 模块文件
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
}
解决方案
推荐阅读
- reactjs - 我已经在 firebase 上部署了 React 项目,但它没有显示我的网站。其节目欢迎页面
- assembly - X86 程序集:.text.startup 部分和 .text 部分有什么区别
- android - 使用 android studio 模拟器在 android api <24 中测试 Google 计费
- docker - 您的构建运行失败:无法读取提交 xxxxxxxx
- javascript - 做出反应,在更改输入数据时保持 Picker 的价值
- c - 如何消除输入中的空格?
- javascript - ThingsBoard:自定义小部件 JQuery 冲突错误
- r - 如何在ggtree中设置特定的提示标签颜色
- tensorflow - 以编程方式检查 Tensorflow SavedModel
- ruby-on-rails - Rails 的模型挂钩会等到数据库事务完成吗?