title: Android gradle multiproject dependency resolution
body: <p>In my Android project I have a task for copying the build dependencies to an external directory as below:</p>
  
  <pre><code>task copyBuildDependencies(type: Copy) {
      delete "$buildDir/dependencies"
      afterEvaluate {
          from configurations.releaseCompileClasspath
          into "$buildDir/dependencies"
  
          doLast {
              FileTree files = fileTree("$buildDir/dependencies")
              files.forEach { file -&gt;
                  if (file.isFile() &amp;&amp; file.name.endsWith(".aar")) {
                      copy {
                          from zipTree(file).matching { include "*.jar" }
                          into "$buildDir/dependencies"
                          eachFile {
                              it.path = it.path.replace(it.name, "${file.name}-${it.name}")
                          }
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>I have normal dependencies with project dependencies:</p>
  
  <pre><code>dependencies {
      implementation fileTree(include: ['*.jar'], dir: 'libs')
      ...
      implementation 'com.google.guava:guava:11.0.2'
      implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
      implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.22.5'
      implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:0.22.5'
      // Note: These are Android Library projects
      implementation project(':genericutils')
      implementation project(':module2')
      ...
  }
  </code></pre>
  
  <p>When I run the task <code>copyBuildDependencies</code> I get the following error:</p>
  
  <pre><code>Executing task 'copyBuildDependencies'...
  
  Executing tasks: [copyBuildDependencies]
  
  Configuration on demand is an incubating feature.
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
  Could not determine the dependencies of task ':BiometricInterfaceLib:copyBuildDependencies'.
  &gt; Could not resolve all task dependencies for configuration ':BiometricInterfaceLib:releaseCompileClasspath'.
  &gt; More than one variant of project :genericutils matches the consumer attributes:
      - Configuration ':genericutils:releaseApiElements' variant android-aidl:
          - Found artifactType 'android-aidl' but wasn't required.
          - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'.
          - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
          - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
      - Configuration ':genericutils:releaseApiElements' variant android-classes:
          - Found artifactType 'android-classes' but wasn't required.
          - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'.
          - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
          - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
      - Configuration ':genericutils:releaseApiElements' variant android-manifest:
          - Found artifactType 'android-manifest' but wasn't required.
          - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'.
          - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
          - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
      - Configuration ':genericutils:releaseApiElements' variant android-renderscript:
          - Found artifactType 'android-renderscript' but wasn't required.
          - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'.
          - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
          - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
      - Configuration ':genericutils:releaseApiElements' variant jar:
          - Found artifactType 'jar' but wasn't required.
          - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'.
          - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
          - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
  &gt; More than one variant of project :module2 matches the consumer attributes:
      - Configuration ':module2:releaseApiElements' variant android-aidl:
          - Found artifactType 'android-aidl' but wasn't required.
          - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'.
          - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
          - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
      - Configuration ':module2:releaseApiElements' variant android-classes:
          - Found artifactType 'android-classes' but wasn't required.
          - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'.
          - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
          - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
      - Configuration ':module2:releaseApiElements' variant android-manifest:
          - Found artifactType 'android-manifest' but wasn't required.
          - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'.
          - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
          - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
      - Configuration ':module2:releaseApiElements' variant android-renderscript:
          - Found artifactType 'android-renderscript' but wasn't required.
          - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'.
          - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
          - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
      - Configuration ':module2:releaseApiElements' variant jar:
          - Found artifactType 'jar' but wasn't required.
          - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'.
          - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
          - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
  
  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
  
  * Get more help at https://help.gradle.org
  
  BUILD FAILED in 2s
  16:39:07: Task execution finished 'copyBuildDependencies'.
  </code></pre>
  
  <p>I can use the exclude module option on <code>configurations.releaseCompileClasspath</code> but then the <code>assembleRelease</code> task fails because it can not find the dependencies.</p>
  
  <p>Edit: I have created an example project to help show the result that I am after and the issue I am having: <a href="https://gitlab.com/crunchy234/android-gradle-dependencies-export" rel="nofollow noreferrer">https://gitlab.com/crunchy234/android-gradle-dependencies-export</a></p>
  
  <p>--- Edit 2 ---</p>
  
  <p>The reason for wanting the dependencies of the library module rather than the Jar for the library is so that a Xamarin Bindings library can be created.</p>
  
  <p>So what is wanted for the Xamarin Bindings is the AAR for the library (mastermodule in the case of the example code) and all of the Jars for the libraries dependencies.
  E.g:</p>
  
  <pre><code>mastermodule/build/dependencies/
  ├── animated-vector-drawable-28.0.0-alpha3.aar-classes.jar
  ├── annotations-13.0.jar
  ...
  ├── collections-28.0.0-alpha3.jar
  ├── common-1.1.1.jar
  ├── coordinatorlayout-28.0.0-alpha3.aar-classes.jar
  ...
  etc
  </code></pre>