Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AmbiguousVariantSelectionException with Android Gradle 3.0 #139

Open
hansinator85 opened this issue Nov 28, 2017 · 22 comments
Open

AmbiguousVariantSelectionException with Android Gradle 3.0 #139

hansinator85 opened this issue Nov 28, 2017 · 22 comments

Comments

@hansinator85
Copy link

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.

@cfsbhawkins
Copy link

I think you are seeing the same issue I am seeing and reported here as well. I actually have had a support ticket open since the release of 3.0 to the masses. I think it has to do with how they parse everything for POM generation.

@romangurevitch
Copy link
Contributor

romangurevitch commented Dec 5, 2017

@hansinator85, @cfsbhawkins,
We have created a new example that works with the latest Android gradle plugin, see the example here.

Command line to run the example:
./gradlew clean artifactoryPublish

Output:

> Task :app:lint
Ran lint on variant release: 3 issues found
Ran lint on variant debug: 3 issues found
Wrote HTML report to file:///home/romang/Work/Devdir/DEV1/project-examples/gradle-examples/4/gradle-android-example/app/build/reports/lint-results.html
Wrote XML report to file:///home/romang/Work/Devdir/DEV1/project-examples/gradle-examples/4/gradle-android-example/app/build/reports/lint-results.xml

> Task :library:lint
Ran lint on variant debug: 2 issues found
Ran lint on variant release: 2 issues found
Wrote HTML report to file:///home/romang/Work/Devdir/DEV1/project-examples/gradle-examples/4/gradle-android-example/library/build/reports/lint-results.html
Wrote XML report to file:///home/romang/Work/Devdir/DEV1/project-examples/gradle-examples/4/gradle-android-example/library/build/reports/lint-results.xml

> Task :library:artifactoryPublish
Deploying artifact: http://localhost:8081/artifactory/libs-snapshot-local/gradle-android-example/app/1.0-SNAPSHOT/app-1.0-SNAPSHOT.apk
Deploying artifact: http://localhost:8081/artifactory/libs-snapshot-local/gradle-android-example/app/1.0-SNAPSHOT/app-1.0-SNAPSHOT.pom
Deploying artifact: http://localhost:8081/artifactory/libs-snapshot-local/gradle-android-example/library/1.0-SNAPSHOT/library-1.0-SNAPSHOT.aar
Deploying artifact: http://localhost:8081/artifactory/libs-snapshot-local/gradle-android-example/library/1.0-SNAPSHOT/library-1.0-SNAPSHOT.pom
Deploying build descriptor to: http://localhost:8081/artifactory/api/build
Build successfully deployed. Browse it in Artifactory under http://localhost:8081/artifactory/webapp/builds/gradle-android-example/1512485352762


BUILD SUCCESSFUL in 22s
118 actionable tasks: 114 executed, 4 up-to-date

Can you please try running the example, it might help us troubleshot the issues you are having.

@cfsbhawkins
Copy link

Do we have to have the following line?
artifactoryPublish.dependsOn('build')

Problem I have with this is the fact that this now build debug, release, all of my build flavors runs lint and tests.

I would prefer to do as I used to since this is done via a CI machine and call ./gradlew assembleDebug artifactoryPublish and it just upload the resulting artifacts from the previous build.

Problem I have with requiring my artifactoryPublish to run my builds is this now takes over 8 minutes on my machine to build. (I have a lot of modules and product variants)

@romangurevitch
Copy link
Contributor

@cfsbhawkins,
You don't have to add the artifactoryPublish.dependsOn('build') dependency.
But before executing artifactoryPublish make sure the artifacts in the publication exist, otherwise it will fail.

@billyjoker
Copy link

@romangurevitch your example link is broken... could you restore it, please?

@romangurevitch
Copy link
Contributor

@billyjoker,
Sure here it is: gradle-android-example.

@agent8261
Copy link

agent8261 commented Mar 9, 2018

I am also getting this problem. I have created a sample project that should help replicate the issue:

https://github.com/agent8261/BugArtifactory

@Ahmedfir
Copy link

I am having exactly the same problem. And just that we don't go in the wrong direction, I am not using any publishing config inside of the project (all deployment config is hapening in jenkins). I am only having my build config in Gradle, so I don't think the publishing config is causing is issue... I have many modules and I am using a lot of dependencies, one of them is Firebase. I am doubting this is related to Firebase.

@tauntz
Copy link

tauntz commented May 14, 2018

Hi, we're seeing the same issue with the Jenkins Artifactory plugin 2.16.1. We don't use the Artifactory Gradle plugin in our Gradle file directly but rather the Jenkins plugin. The builds started to fail with the same/similar failure:

Error during extraction: 
org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':mobile:flavourCompileClasspath'.
...
Caused by: org.gradle.internal.component.AmbiguousVariantSelectionException: More than one variant of project :library matches the consumer attributes:
...

Just in case, it's an Android project that has multiple Gradle modules and uses Gradle 4.6 & com.android.tools.build:gradle:3.1.2

@eyalbe4
Copy link
Contributor

eyalbe4 commented May 16, 2018

I reproduced this issue using the sample project provided by @agent826 (Thanks you @agent826).
This exception is thrown by the ** resolvedConfiguration.getResolvedArtifacts()** gradle API.
See the below code snippet which uses this API in the org.jfrog.gradle.plugin.artifactory.extractor.GradleBuildInfoExtractor class.

    private List<Dependency> calculateDependencies(Project project) throws Exception {
        Set<Configuration> configurationSet = project.getConfigurations();
        List<Dependency> dependencies = newArrayList();
        for (Configuration configuration : configurationSet) {
            if (configuration.getState() != Configuration.State.RESOLVED) {
                log.info("Artifacts for configuration '{}' were not all resolved, skipping", configuration.getName());
                continue;
            }
            ResolvedConfiguration resolvedConfiguration = configuration.getResolvedConfiguration();
            Set<ResolvedArtifact> resolvedArtifactSet = resolvedConfiguration.getResolvedArtifacts();

I opened issue gradle/gradle#5426 to the gradle team, hoping to get some guidance on the best approach to handle this exception.

@juanchosaravia
Copy link

Does anyone found at least a workaround to this?

@blind3dd
Copy link

This is biting us too and we wonder does anybody at least know a way to work around this?

@stealthrabbi
Copy link

I'm also getting this issue. I've reached out to JFrog Support email but haven't heard anything yet.

@amg
Copy link

amg commented Aug 12, 2020

I also got the same issue, using android gradle plugin 4.0.0. I got 3 modules: app, demo and library itself. app is used for visual and demo and library are both libs.

@nateridderman-lilly
Copy link

My workaround is to not use this plugin. I switched to the maven-publish plugin, which also can easily build the AAR and POM files since Android Studio 3.6. Just add a repositories section to the config. As a bonus, it also publishes the Gradle module metadata, which is a new format similar to POM.

Plugin documentation: https://docs.gradle.org/current/userguide/publishing_maven.html#publishing_maven

@JCreswellENVRMNT
Copy link

JCreswellENVRMNT commented Nov 16, 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 sonatype-nexus-community/scan-gradle-plugin#41 (comment), 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.

@Pete-Degree53
Copy link

Pete-Degree53 commented 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, I begin to get unresolved references when trying to access anything in the dependency in question.

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

@JCreswellENVRMNT
Copy link

JCreswellENVRMNT commented 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).

@Sanheethaa
Copy link

Sanheethaa commented Sep 4, 2023

Hi, I am still facing the issue with plugin 7.4.2 version. Even with maven publish, I am getting the error.Are there any alternative workarounds that have been successful in resolving this issue for others?

@yahavi
Copy link
Member

yahavi commented Sep 5, 2023

@Sanheethaa,
This issue should be fixed in the Gradle Artifactory plugin 5.1.0 by jfrog/artifactory-gradle-plugin#46.
Please feel free to upgrade to the latest version and share your feedback.

@yahavi
Copy link
Member

yahavi commented Sep 5, 2023

@Sanheethaa what is your Gradle Artifactory plugin version?

@Sanheethaa
Copy link

@Sanheethaa what is your Gradle Artifactory plugin version?

That was 4.24.9. With 5.1.0, the issue is not seen. thank you so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests