I have a gradle android library module that depends on another project android library:
androidlib-a depends on androidlib-b
androidlib-a dependency
implementation project(path: ':androidlib-b', configuration: "default")
Following exception is thrown in configuration phase after upgrading to android build tools 3.5.0 from 3.3.0:
What went wrong: Could not determine the dependencies of task ':androidlib-a:lint'. Could not resolve all artifacts for configuration ':androidlib-a:releaseCompileClasspath'. Failed to transform artifact 'androidlib-b.aar (project :androidlib-b)' to match attributes {artifactType=jar}. Execution failed for IdentityTransform: C:\LocalData\projects\project\androidlib-b\build\outputs\aar\androidlib-b-release.aar. C:\LocalData\projects\project\androidlib-b\build\outputs\aar\androidlib-b-release.aar.
I change the androidlib-a dependency to:
implementation project(':androidlib-b')
The build for androidlib-a from command line works now but I get following issue on an Android Studio Gradle Sync:
ERROR: More than one variant of project :androidlib-b matches the consumer attributes: - Configuration ':androidlib-b:releaseRuntimeElements' variant android-assets: - Unmatched attributes: - Found artifactType 'android-assets' but wasn't required. - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required. - Compatible attributes: - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'. - Configuration ':androidlib-b:releaseRuntimeElements' variant android-classes: - Unmatched attributes: - Found artifactType 'android-classes' but wasn't required. - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required. - Compatible attributes: - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'. - Configuration ':androidlib-b:releaseRuntimeElements' variant android-consumer-proguard-rules: ...
After the change I have also an issue in another module that depends on androidlib-a and tries to copy the dependencies like that:
task copyToLib() {
afterEvaluate {
dependsOn ":androidlib-a:assembleRelease"
}
doLast {
delete libDir
def config = rootProject.project(":project").configurations.releaseRuntimeClasspath
println config.toList()
copy {
into libDir
from config
}
}
}
preBuild.dependsOn "copyToLib"
Execution failed for task ':anothermodule:copyToLib'. Could not resolve all files for configuration ':androidlib-a:releaseRuntimeClasspath'. More than one variant of project :androidlib-b matches the consumer attributes: - Configuration ':androidlib-b:releaseRuntimeElements' variant android-assets: - Unmatched attributes: - Found artifactType 'android-assets' but wasn't required. - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required. - Compatible attributes: - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'. - Configuration ':androidlib-b:releaseRuntimeElements' variant android-classes: - Unmatched attributes: - Found artifactType 'android-classes' but wasn't required. - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required. - Compatible attributes: - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
Same issues are present with android build tools 3.5.1 release.
Full androidlib-a build conifg:
apply plugin: 'com.android.library'
version = releaseVersion
android {
compileSdkVersion 27
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName releaseVersion
}
buildTypes {
release {
minifyEnabled false
}
}
}
dependencies {
implementation project(path: ':androidlib-b', configuration: "default")
}
Full androidlib-b build conifg:
apply plugin: 'com.android.library'
version = releaseVersion
android {
compileSdkVersion 27
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName releaseVersion
}
buildTypes {
release {
minifyEnabled false
}
}
}