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

Could not resolve all task dependencies for configuration #1108

Open
Anigif opened this issue Jan 22, 2024 · 9 comments
Open

Could not resolve all task dependencies for configuration #1108

Anigif opened this issue Jan 22, 2024 · 9 comments

Comments

@Anigif
Copy link

Anigif commented Jan 22, 2024

Plugin version
1.28.0 (and 1.29.0)

Gradle version
8.2

JDK version
17

(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version
Kotlin 1.9.21

(Optional) Android Gradle Plugin (AGP) version
8.2.1

Describe the bug
After bumping to 1.28.0 we get this error when building the project (for instance via build):

Could not determine the dependencies of task ':moduleA:extractDebugAnnotations'.
> Could not resolve all task dependencies for configuration ':moduleA:debugCompileClasspath'.
   > Could not resolve project :moduleB.
     Required by:
         project :moduleA
      > The consumer was configured to find a library for use during compile-time, 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 '8.2.1', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'. However we cannot choose between the following variants of project :moduleB:
          - projectHealthElements
          - resolvedDepsElements
        All of them match the consumer attributes:
          - Variant 'projectHealthElements' capability rootProject:moduleB:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.android.build.api.attributes.AgpVersionAttr (required '8.2.1')
                  - Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
                  - Provides attribute 'dagp.internal.artifacts' with value 'project-health' but the consumer didn't ask for it
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about its target Java environment (preferred optimized for Android)
                  - Doesn't say anything about its usage (required compile-time)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'androidJvm')
          - Variant 'resolvedDepsElements' capability rootProject:moduleB:unspecified:
              - Unmatched attributes:
                  - Doesn't say anything about com.android.build.api.attributes.AgpVersionAttr (required '8.2.1')
                  - Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
                  - Provides attribute 'dagp.internal.artifacts' with value 'resolved-deps' but the consumer didn't ask for it
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about its target Java environment (preferred optimized for Android)
                  - Doesn't say anything about its usage (required compile-time)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'androidJvm')

moduleA is here a regular module (with plugin com.android.library) and moduleB is a "wrapper" around an AAR file to be able to use it. The AAR file is included like this:

configurations.maybeCreate("default")
artifacts.add("default", file('someExternalLib.aar'))

This is not how the official documentation states it, but due to a weird bug this doesn't work for other reasons unfortunately.

I don't know if we can fix this in any other ways (is it possible to ignore dependencies or modules somehow?), so wanted to file this bug if you weren't aware of this. And for the record, it works fine for version 1.27.0.

@Anigif
Copy link
Author

Anigif commented Jan 27, 2024

Just for the record, I've now submitted a bug report for the solution stated by the official documentation. Hopefully it will get fixed, but it might still be worth figuring out why the other setup mentioned above doesn't work.

@autonomousapps autonomousapps added bug Something isn't working toolchain:android labels Feb 22, 2024
@autonomousapps
Copy link
Owner

I think that other configuration you create needs to have some metadata attached to it. If you provide a reproducer I can take a look and see if there's something I can do in DAGP.

@papo2608
Copy link

@autonomousapps here we go:
reproducer-issue-1108.zip

Thanks!

@autonomousapps
Copy link
Owner

I've just resolved another issue that looks at least superficially similar. Could you try the latest snapshot (wait at least an hour from when I post this message)?

@eduardbosch-jt
Copy link

Hey @autonomousapps,

Thanks for the update. Unfortunately, I've tested 1.31.1-SNAPSHOT and it didn't solve this issue. At least on my side.

@autonomousapps
Copy link
Owner

Alright, thanks! Looks like something that might be Android-specific.

@autonomousapps
Copy link
Owner

I was able to workaround this by adding this to the top of the "wrapper" module:

// wrapper-module/build.gradle
plugins {
  id("java")
}

I find the existence of such modules unusual -- what's the use-case? Why not just add the jar as a dependency to "normal" modules directly?

@bidrohi
Copy link

bidrohi commented May 24, 2024

For Android projects, it throws a lint error since adding AAR files directly misses the non-JVM parts of the archive.

@autonomousapps
Copy link
Owner

For Android projects, it throws a lint error since adding AAR files directly misses the non-JVM parts of the archive.

What exactly throws a lint error?

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

No branches or pull requests

5 participants