问题
Minimum supported gradle version 4.6 Current version is 4.4.
After updating gradle version to 4.6, am getting this error
Cannot add task ':app:reportSourceSetTransformTest' as a task with that name already exists.
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.
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
}
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'
}
回答1:
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)
来源:https://stackoverflow.com/questions/52257747/cannot-add-task-appreportsourcesettransformtest-as-a-task-with-that-name-alr