美文网首页
Cannot add task 'clean' as a tas

Cannot add task 'clean' as a tas

作者: a_simple_coder | 来源:发表于2022-05-12 15:46 被阅读0次

    运行程序报以下问题:

    Build file '/Users/zhouruoqi/Documents/codes/jingbeifang/jimu/jiyu-app/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.
    
    * Try:
    Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Exception is:
    org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:92)
        ... 102 more
    Caused by: org.gradle.api.InvalidUserDataException: Cannot add task 'clean' as a task with that name already exists.
        at org.gradle.api.internal.tasks.DefaultTaskContainer.duplicateTask(DefaultTaskContainer.java:215)
        ... 163 more
    
    

    解决方法

    Android Studio's Gradle wrapper 已经定义了 clean 的 task,所以无需重复定义:删除Project目录下的 build.gradle文件中

        task clean(type: Delete) {
            delete rootProject.buildDir
        }
    

    参考链接:https://stackoverflow.com/questions/55118903/error-cannot-add-task-clean-as-a-task-with-that-name-already-exists

    相关文章

      网友评论

          本文标题:Cannot add task 'clean' as a tas

          本文链接:https://www.haomeiwen.com/subject/pkzsurtx.html