autonomousapps / autonomousapps/dependency-analysis-gradle-plugin

Could not resolve all task dependencies for configuration

Open
#1,108 23 comments 3 reactions 0 assignees View on GitHub
bug more information needed toolchain:android
Dominant language
Kotlin
Stars
2.2k
Forks
158
Avg merge
16h 25m
Merged PRs (30d)
46

Description

**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](https://developer.android.com/studio/projects/android-library#psd-add-aar-jar-dependency) states it, but due to a [weird bug](https://stackoverflow.com/questions/60878599/error-building-android-library-direct-local-aar-file-dependencies-are-not-supp) 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.

Contributor guide

Open the contributing guide

Research direction

Reproduce the `build` failure with Gradle 8.2, JDK 17, Kotlin 1.9.21, AGP 8.2.1, and plugin 1.28.0 or 1.29.0 using the described `moduleA` and AAR-wrapper `moduleB` setup. Inspect the dependency configurations and variant selection, then verify that `moduleA` resolves `moduleB` without the ambiguous `projectHealthElements` and `resolvedDepsElements` variants.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
build-system, mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.