1

I'm stuck listing transitive closure of runtime dependencies in Gradle Android project. Trying to do it like this:

task listDependencies {
  doLast {
    def configuration = project.configurations.debugRuntimeClasspath
    for (file in configuration.files) {
      println(file)
    }
  }
}

However, this produces following error:

Execution failed for task ':***:listDependencies'.
> Could not resolve all files for configuration ':***:debugRuntimeClasspath'.
   > The consumer was configured to find a runtime of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug'. However we cannot choose between the following variants of project :***:
       - Configuration ':***:debugRuntimeElements' variant android-aar-metadata declares a runtime of a component, as well as 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.api.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
       - Configuration ':***:debugRuntimeElements' variant android-assets declares a runtime of a component, as well as 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.api.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
       - Configuration ':***:debugRuntimeElements' variant android-classes-directory declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug':
Alexey Andreev
  • 1,980
  • 2
  • 17
  • 29
  • See this: https://stackoverflow.com/questions/65689788/could-not-resolve-all-files-for-configuration-appdebugruntimeclasspath – c-an May 11 '21 at 16:01
  • @c-an seems that it's another issue, at least caused by another reason. The issue you refer is caused by some network/cryptography reasons. – Alexey Andreev May 11 '21 at 16:18
  • This looks like an error in variant selection. See [Variant selection errors](https://docs.gradle.org/current/userguide/variant_model.html#sec:variant-select-errors) for more information. Unclear without more info about what the fix would be Maybe the link will help. – Cheticamp May 14 '21 at 15:04
  • @Cheticamp I don't know gradle at all. I have some legacy build scripts that I cannot share here and have no idea how they work. Looks like they are trivial (just apply android plugin and declare dependencies). I don't know what are components and variants and how they apply to Android build configuration. What kind of information I can provide to make it clear how to fix the issue? – Alexey Andreev May 14 '21 at 15:47
  • I think that the Gradle files would be helpful, but you can't share them. Try specifying `def configuration = project(":app").configurations.debugRuntimeClasspath` to see if that makes any difference. ":app" would be your module name. Other than that, maybe someone has advice on how to select among ambiguous variants. – Cheticamp May 14 '21 at 17:11
  • 1
    Also this might help to just view all dependencies: https://stackoverflow.com/a/35235229/6287910 – Cheticamp May 14 '21 at 20:28

0 Answers0