无法添加任务':app:reportSourceSetTransformTest',因为该名称的任务已经存在 [英] Cannot add task ':app:reportSourceSetTransformTest' as a task with that name already exists

查看:380
本文介绍了无法添加任务':app:reportSourceSetTransformTest',因为该名称的任务已经存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Minimum supported gradle version 4.6 Current version is 4.4.

将gradle版本更新为4.6后,出现此错误

After updating gradle version to 4.6, am getting this error

Cannot add task ':app:reportSourceSetTransformTest' as a task with that name already exists.

如何避免此错误.似乎两个不同的文件具有相同的任务.但是我没有在应用程序级别的build.gradle文件中找到任何任务或未明确定义任何任务.

How can I avoid this error. It seems like two different files have same task. But I didnot find any or explicitly define any task in my app level build.gradle file.

我的项目级别build.gradle文件是这样的:

My project level build.gradle file is this:

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
        maven { url 'https://maven.google.com' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
        classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-SNAPSHOT'
        classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1'
    }
}
allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
        maven { url 'https://maven.google.com' }
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

和应用级build.gradle文件是这样的:

and app level build.gradle file is this:

apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.1'
    flavorDimensions "default"
    defaultConfig {
        applicationId "com.applicationId"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 3
        versionName "1.0.2"
        vectorDrawables.useSupportLibrary = true
    }
    aaptOptions {
        cruncherEnabled = false
    }
    lintOptions {
        abortOnError false
        checkReleaseBuilds false
    }
  }

dependencies {
    implementation project(':demo')
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    androidTestImplementation('junit:junit:4.12')
    implementation 'com.github.ViksaaSkool:AwesomeSplash:v1.0.0'
}

推荐答案

就我而言,我的口味名称和新的gradle插件发生冲突. 当我更改口味的名称(生产,测试)->(生产,开发)时,该问题已解决.

In my case I had a conflict with my flavour name and new gradle plugin. The problem was solved when I changed the names of my flavours (Production, Test) -> (production, develop)

这篇关于无法添加任务':app:reportSourceSetTransformTest',因为该名称的任务已经存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆