其他分享
首页 > 其他分享> > android-无法添加任务’:app:reportSourceSetTransformTest’,因为该名称的任务已经存在

android-无法添加任务’:app:reportSourceSetTransformTest’,因为该名称的任务已经存在

作者:互联网

Minimum supported gradle version 4.6 Current version is 4.4.

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

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

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

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

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文件是这样的:

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插件存在冲突.
当我更改口味名称(生产,测试)时,问题已解决. (生产,开发)

标签:android-gradle,build-gradle,gradle,android
来源: https://codeday.me/bug/20191108/2008931.html