question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AmbiguousVariantSelectionException with Android Gradle 3.0

See original GitHub issue

Since upgrading to Android Gradle 3.0 (actually 3.0.1) with Gradle 4.3 we are not getting dependencies anymore.

The build info is not showing any dependencies. When doing the artifactoryPublish with --debug we see the following error occur (might be the issue?):

18:00:31 17:00:31.976 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected matches [configuration ':library1:releaseApiElements' variant android-aidl, configuration ':library1:releaseApiElements' variant android-classes, configuration ':library1:releaseApiElements' variant android-manifest, configuration ':library1:releaseApiElements' variant android-renderscript, configuration ':library1:releaseApiElements' variant jar] from candidates [configuration ':library1:releaseApiElements' variant android-aidl, configuration ':library1:releaseApiElements' variant android-classes, configuration ':library1:releaseApiElements' variant android-manifest, configuration ':library1:releaseApiElements' variant android-renderscript, configuration ':library1:releaseApiElements' variant jar] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.978 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected matches [configuration ':library2:releaseApiElements' variant android-aidl, configuration ':library2:releaseApiElements' variant android-classes, configuration ':library2:releaseApiElements' variant android-manifest, configuration ':library2:releaseApiElements' variant android-renderscript, configuration ':library2:releaseApiElements' variant jar] from candidates [configuration ':library2:releaseApiElements' variant android-aidl, configuration ':library2:releaseApiElements' variant android-classes, configuration ':library2:releaseApiElements' variant android-manifest, configuration ':library2:releaseApiElements' variant android-renderscript, configuration ':library2:releaseApiElements' variant jar] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.978 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected match at.iaik:cms:5.1 configuration default from candidates [at.iaik:cms:5.1 configuration default] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.978 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected match at.iaik:jce_full:5.3 configuration default from candidates [at.iaik:jce_full:5.3 configuration default] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.978 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected match at.iaik:pki_module:0.10 configuration default from candidates [at.iaik:pki_module:0.10 configuration default] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.979 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected match com.android.support:support-v4:26.0.2 configuration default from candidates [com.android.support:support-v4:26.0.2 configuration default] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.979 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected match com.android.support:support-media-compat:26.0.2 configuration runtime from candidates [com.android.support:support-media-compat:26.0.2 configuration runtime] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.979 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected match com.android.support:support-fragment:26.0.2 configuration runtime from candidates [com.android.support:support-fragment:26.0.2 configuration runtime] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.979 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected match com.android.support:support-core-utils:26.0.2 configuration runtime from candidates [com.android.support:support-core-utils:26.0.2 configuration runtime] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.979 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected match com.android.support:support-core-ui:26.0.2 configuration runtime from candidates [com.android.support:support-core-ui:26.0.2 configuration runtime] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.979 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected match com.android.support:support-compat:26.0.2 configuration runtime from candidates [com.android.support:support-compat:26.0.2 configuration runtime] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.979 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected match com.android.support:support-annotations:26.0.2 configuration default from candidates [com.android.support:support-annotations:26.0.2 configuration default] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.979 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected match com.android.support:support-annotations:26.0.2 configuration runtime from candidates [com.android.support:support-annotations:26.0.2 configuration runtime] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.979 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected match com.google.guava:guava:20.0 configuration default from candidates [com.google.guava:guava:20.0 configuration default] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.979 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected match com.squareup.okhttp3:logging-interceptor:3.9.1 configuration default from candidates [com.squareup.okhttp3:logging-interceptor:3.9.1 configuration default] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.979 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected match com.squareup.okhttp3:okhttp:3.9.1 configuration default from candidates [com.squareup.okhttp3:okhttp:3.9.1 configuration default] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.979 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected match com.squareup.okhttp3:okhttp:3.9.1 configuration runtime from candidates [com.squareup.okhttp3:okhttp:3.9.1 configuration runtime] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.980 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected match com.squareup.okio:okio:1.13.0 configuration default from candidates [com.squareup.okio:okio:1.13.0 configuration default] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.980 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected match com.squareup.okio:okio:1.13.0 configuration runtime from candidates [com.squareup.okio:okio:1.13.0 configuration runtime] for {branding=appBranding, com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.api.attributes.Usage=java-api}
18:00:31 17:00:31.980 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Build operation 'Resolve files of :app:appBrandingReleaseCompileClasspath' started
18:00:31 17:00:31.980 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Completing Build operation 'Resolve files of :app:appBrandingReleaseCompileClasspath'
18:00:31 17:00:31.980 [ERROR] [org.jfrog.gradle.plugin.artifactory.extractor.GradleBuildInfoExtractor] Error during extraction: 
18:00:31 org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':app:appBrandingReleaseCompileClasspath'.
18:00:31 	at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver.wrapException(ErrorHandlingConfigurationResolver.java:96)
18:00:31 	at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver.access$000(ErrorHandlingConfigurationResolver.java:45)
18:00:31 	at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver$ErrorHandlingResolvedConfiguration.getResolvedArtifacts(ErrorHandlingConfigurationResolver.java:298)
18:00:31 	at org.jfrog.gradle.plugin.artifactory.extractor.GradleBuildInfoExtractor.calculateDependencies(GradleBuildInfoExtractor.java:329)
18:00:31 	at org.jfrog.gradle.plugin.artifactory.extractor.GradleBuildInfoExtractor.extractModule(GradleBuildInfoExtractor.java:292)
18:00:31 	at org.jfrog.gradle.plugin.artifactory.extractor.GradleBuildInfoExtractor.extract(GradleBuildInfoExtractor.java:118)
18:00:31 	at org.jfrog.gradle.plugin.artifactory.task.BuildInfoBaseTask.prepareAndDeploy(BuildInfoBaseTask.java:486)
18:00:31 	at org.jfrog.gradle.plugin.artifactory.task.BuildInfoBaseTask.collectProjectBuildInfo(BuildInfoBaseTask.java:129)
18:00:31 	at org.jfrog.gradle.plugin.artifactory.task.BuildInfoBaseTask.taskAction(BuildInfoBaseTask.java:116)
18:00:31 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
18:00:31 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
18:00:31 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
18:00:31 	at java.lang.reflect.Method.invoke(Method.java:498)
18:00:31 	at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
18:00:31 	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
18:00:31 	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
18:00:31 	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
18:00:31 	at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:784)
18:00:31 	at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:751)
18:00:31 	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
18:00:31 	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
18:00:31 	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
18:00:31 	at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
18:00:31 	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
18:00:31 	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
18:00:31 	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
18:00:31 	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
18:00:31 	at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
18:00:31 	at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
18:00:31 	at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
18:00:31 	at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
18:00:31 	at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
18:00:31 	at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
18:00:31 	at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
18:00:31 	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
18:00:31 	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
18:00:31 	at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
18:00:31 	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
18:00:31 	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
18:00:31 	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
18:00:31 	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
18:00:31 	at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
18:00:31 	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
18:00:31 	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
18:00:31 	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
18:00:31 	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
18:00:31 	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
18:00:31 	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
18:00:31 	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
18:00:31 	at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
18:00:31 	at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
18:00:31 	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
18:00:31 	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
18:00:31 	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
18:00:31 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
18:00:31 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
18:00:31 	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
18:00:31 	at java.lang.Thread.run(Thread.java:748)
18:00:31 Caused by: org.gradle.internal.component.AmbiguousVariantSelectionException: More than one variant of project :library1 matches the consumer attributes:
18:00:31   - Configuration ':library1:releaseApiElements' variant android-aidl:
18:00:31       - Found artifactType 'android-aidl' but wasn't required.
18:00:31       - Required branding 'appBranding' but no value provided.
18:00:31       - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'.
18:00:31       - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
18:00:31       - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
18:00:31       - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
18:00:31   - Configuration ':library1:releaseApiElements' variant android-classes:
18:00:31       - Found artifactType 'android-classes' but wasn't required.
18:00:31       - Required branding 'appBranding' but no value provided.
18:00:31       - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'.
18:00:31       - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
18:00:31       - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
18:00:31       - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
18:00:31   - Configuration ':library1:releaseApiElements' variant android-manifest:
18:00:31       - Found artifactType 'android-manifest' but wasn't required.
18:00:31       - Required branding 'appBranding' but no value provided.
18:00:31       - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'.
18:00:31       - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
18:00:31       - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
18:00:31       - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
18:00:31   - Configuration ':library1:releaseApiElements' variant android-renderscript:
18:00:31       - Found artifactType 'android-renderscript' but wasn't required.
18:00:31       - Required branding 'appBranding' but no value provided.
18:00:31       - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'.
18:00:31       - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
18:00:31       - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
18:00:31       - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
18:00:31   - Configuration ':library1:releaseApiElements' variant jar:
18:00:31       - Found artifactType 'jar' but wasn't required.
18:00:31       - Required branding 'appBranding' but no value provided.
18:00:31       - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'.
18:00:31       - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
18:00:31       - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
18:00:31       - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
18:00:31 	at org.gradle.api.internal.artifacts.transform.DefaultArtifactTransforms$AttributeMatchingVariantSelector.doSelect(DefaultArtifactTransforms.java:101)
18:00:31 	at org.gradle.api.internal.artifacts.transform.DefaultArtifactTransforms$AttributeMatchingVariantSelector.select(DefaultArtifactTransforms.java:88)
18:00:31 	at org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.DefaultArtifactSet.select(DefaultArtifactSet.java:123)
18:00:31 	at org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.DefaultVisitedArtifactResults.select(DefaultVisitedArtifactResults.java:48)
18:00:31 	at org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration.select(DefaultLenientConfiguration.java:112)
18:00:31 	at org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration.select(DefaultLenientConfiguration.java:101)
18:00:31 	at org.gradle.api.internal.artifacts.ivyservice.DefaultResolvedConfiguration.getResolvedArtifacts(DefaultResolvedConfiguration.java:78)17:00:31.982 [DEBUG] 

We have a multi module project with kind of following structure (i’ll try to describe as good as possible, can’t give you the project of course and would take some time to construct a sample):

  • app (has one flavorDimension and some flavors)
  • library1 (does UI stuff)
  • library2 (does requests, parsing, holding data)

Working old configuration with Android Gradle 2.3.3 and Gradle 3.3

  • library2 has some dependencies (like guava, okhttpclient, …)
  publishNonDefault true
dependencies {
  compile 'com.google.guava:guava:' + rootProject.ext.guavaVersion
  compile 'com.squareup.okhttp3:okhttp:' + rootProject.ext.OKHttpClientVersion
  compile 'com.squareup.okio:okio:' + rootProject.ext.OKIOVersion
  ...
}

  • library1 has dependency to library2
  publishNonDefault true
dependencies {
  releaseCompile project(path: ':library2', configuration: 'release')
  debugCompile project(path: ':library2', configuration: 'debug')
}

  • app has dependency to library1
dependencies {
  releaseCompile project(path: ':library1 ', configuration: 'release')
  debugCompile project(path: ':library1 ', configuration: 'debug')
}

Current configuration with Android Gradle 3.0.1 and Gradle 4.3

  • library2 has some dependencies (like guava, okhttpclient, …)
dependencies {
  api 'com.google.guava:guava:' + rootProject.ext.guavaVersion
  api 'com.squareup.okhttp3:okhttp:' + rootProject.ext.OKHttpClientVersion
  api 'com.squareup.okio:okio:' + rootProject.ext.OKIOVersion
  ...
}
  • library1 has dependency to library2
dependencies {
  api project(':library2')
}

  • app has dependency to library1
dependencies {
  api project(':library1')
}

So we removed publishNonDefault and instead of compile with separate configuration specification we use api as stated by the android documentation. Use variant-aware dependency management

The application builds as expected. So the dependencies seem to be defined correctly, but somehow there is an issue during resolving for build info dependencies.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:18
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
JCreswellENVRMNTcommented, Nov 17, 2021

Greetings from the world of tomorrow! This is still happening in late 2021 with the latest plugin version 4.24.23

EDIT: this issue can be trivially reproduced using the sample project https://github.com/jfrog/project-examples/tree/master/gradle-examples/gradle-android-example by adding a second library module e.g. lib2 and then add a project dependency on ‘lib2’ in the ‘library’ module’s build.gradle e.g. implementation project(path: ':lib2')

EDIT2: it’s possible to work around this issue by changing the project dependency to implementation project(path: ':lib2', configuration: 'default') per the discussion at https://github.com/sonatype-nexus-community/scan-gradle-plugin/issues/41#issuecomment-686795853, which incidentally is a plugin that had this problem and apparently fixed it. Not sure what the configuration arg is doing or why this helps, but it seems to.

1reaction
JCreswellENVRMNTcommented, Jul 25, 2022

Hi. I’m still facing this problem with plugin version 4.29.0 and the work around seems to cause other issues. Basically, when adding the specific default configuration, a being to get unresolved references when trying to access anything in the dependency in question.

Has the been any progress on resolving? Or any other potential workarounds (other than not using the plugin)?

IIRC the ‘solution’ I went with was to remove the from components.mybuildvariant from my Maven publication definition and instead manually write out my transitive dependencies to the POM file with

pom.withXml {
                    def dependenciesNode = asNode().appendNode('dependencies')
                    // iterate over the implementation dependencies (we don't want the test ones), adding a <dependency> node for each
                    configurations.implementation.allDependencies.each {
                        // need to check if the dependency is sane before writing it in; sometimes
                        // local deps (project or prebuilts in libs dir etc.) will come in with unspecified
                        // properties, which means they need special handling
                        if (it.version.toString().toLowerCase() != "unspecified"
                                && it.name.toString().toLowerCase() != "unspecified"
                                && it.group.toString().toLowerCase() != "unspecified") {
                            def dependencyNode = dependenciesNode.appendNode('dependency')
                            dependencyNode.appendNode('groupId', it.group)
                            dependencyNode.appendNode('artifactId', it.name)
                            dependencyNode.appendNode('version', it.version)
                        }
                    }
                }

For whatever reason, when I don’t use the from components... API this bug doesn’t occur (at least in build-info plugin v4.24.23).

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - org.gradle.internal.component ... - Stack Overflow
After using gradle project as library in my android studio project I get the AmbiguousVariantSelectionException exceptions.
Read more >
More than one variant of project" while syncing Android project
Caused by: org.gradle.internal.component.AmbiguousVariantSelectionException: More than one variant of project :core matches the consumer attributes: ...
Read more >
Android Gradle plugin release notes - Android Developers
The Android Studio build system is based on Gradle, and the Android Gradle plugin adds several features that are specific to building Android...
Read more >
Flutter gradle构建时报错:More than one variant of project ...
Android原生项目创建了个flutter module,然后在的app module中添加implementation ... AmbiguousVariantSelectionException with Android Gradle 3.0.
Read more >
Gradle User Manual
Using existing Gradle builds. Gradle supports many major IDEs, including Android Studio, Eclipse, IntelliJ IDEA, Visual Studio 2019, and XCode. You can also ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found