# Variant selection with multiple values

**URL:** <https://discuss.gradle.org/t/variant-selection-with-multiple-values/42794>\
**Category:** Help/Discuss\
**Created:** [April 26, 2022, 9:52am UTC](https://discuss.gradle.org/t/variant-selection-with-multiple-values/42794 "2022-04-26T09:52:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tdelhomenie](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/tdelhomenie/32/9722_2.png) [@tdelhomenie](https://discuss.gradle.org/u/tdelhomenie)\
**Post date:** [April 26, 2022, 9:52am UTC](https://discuss.gradle.org/t/variant-selection-with-multiple-values/42794/1 "2022-04-26T09:52:05Z")

</div>

Hi,  
I have a multi-project with 1 subproject depending on other subprojects and external dependencies. These subprojects can be java libraries or Android libraries. I need to search for files in all the dependencies. When I try to get the classpath with `project.configurations.debugRuntimeClasspath.each { ... }` I get the following error:

```gradle
Execution failed for task ':Wearable:processMicroejConstants'.
> Could not resolve all files for configuration ':Wearable:debugRuntimeClasspath'.
   > The consumer was configured to find a runtime of a component, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3'. However we cannot choose between the following variants of project :watchfacehelper:
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-aar-metadata declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-aar-metadata' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-art-profile declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-art-profile' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-assets declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-assets' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-classes-directory-Aorg.gradle.libraryelements=classes declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-classes-directory' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
               - Provides its elements preferably in the form of class files but the consumer didn't ask for it
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-classes-jar declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-classes-jar' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
               - Provides its elements packaged as a jar but the consumer didn't ask for it
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-compiled-dependencies-resources declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-compiled-dependencies-resources' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-consumer-proguard-rules declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-consumer-proguard-rules' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-java-res declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-java-res' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
               - Provides its elements packaged as a jar but the consumer didn't ask for it
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-jni declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-jni' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-lint declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-lint' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
               - Provides its elements packaged as a jar but the consumer didn't ask for it
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-lint-local-aar declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-lint-local-aar' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-lint-model-metadata declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-lint-model-metadata' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-lint-variant-dependencies-model declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-lint-variant-dependencies-model' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-lint-variant-dependencies-partial-results declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-lint-variant-dependencies-partial-results' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-manifest declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-manifest' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-navigation-json declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-navigation-json' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-public-res declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-public-res' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-res declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-res' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-symbol declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-symbol' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
       - Configuration ':watchfacehelper:debugRuntimeElements' variant android-symbol-with-package-name declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-symbol-with-package-name' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
       - Configuration ':watchfacehelper:debugRuntimeElements' variant jar declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.3', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'jar' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
               - Provides its elements packaged as a jar but the consumer didn't ask for it

```

It seems there is no default fallback for Android Library, so the `artifactType` attribute must be defined explicitly. But if I use the `artifactType` attribute (for example to `android-classes-jar`), it fails for other dependencies types which do not have this variant.

Is there a way to define multiple values for an attribute for variant selection?  
In the case it is not possible, is there a way to get the artifacts of a configuration and excluding the dependencies having a given plugin (`com.android.library`)?

---

<div class="post-metadata">

**Author:** ![tdelhomenie](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/tdelhomenie/32/9722_2.png) [@tdelhomenie](https://discuss.gradle.org/u/tdelhomenie)\
**Post date:** [May 30, 2022, 7:02pm UTC](https://discuss.gradle.org/t/variant-selection-with-multiple-values/42794/2 "2022-05-30T19:02:37Z")

</div>

I solved my problem by using custom configurations for non Android Library dependencies to resolve them differently.

---

<div class="post-metadata">

**Author:** ![rexmtorres](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/rexmtorres/32/11498_2.png) [@rexmtorres](https://discuss.gradle.org/u/rexmtorres)\
**Post date:** [February 6, 2025, 1:36am UTC](https://discuss.gradle.org/t/variant-selection-with-multiple-values/42794/3 "2025-02-06T01:36:43Z")

</div>

Can you expound on your solution? I’m having the same issue.

---

<div class="post-metadata">

**Author:** ![tdelhomenie](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/tdelhomenie/32/9722_2.png) [@tdelhomenie](https://discuss.gradle.org/u/tdelhomenie)\
**Post date:** [February 24, 2025, 2:41pm UTC](https://discuss.gradle.org/t/variant-selection-with-multiple-values/42794/4 "2025-02-24T14:41:01Z")

</div>

I created a custom configuration and used this configuration to declare the library dependencies in which I wanted to search files in (non-Android library). The drawback is that the developer must know if a library is a Android library or not, to use the right configuration, but it works.
