autonomousapps / autonomousapps/dependency-analysis-gradle-plugin

Clarify `reason` output. Rearrange sections, add more explanatory narrative.

Open
#1,418 7 comments 0 reactions 0 assignees View on GitHub
enhancement sponsorable
Dominant language
Kotlin
Stars
2.2k
Forks
158
Avg merge
16h 25m
Merged PRs (30d)
46

Description

**Plugin version**
2.16.0

**Gradle version**
8.13

**JDK version**
17

**Kotlin and Kotlin Gradle Plugin (KGP) version**
2.1.20

**Android Gradle Plugin (AGP) version**
8.9.1

**`reason` output for bugs relating to incorrect advice**
```
> Task :app:reason

------------------------------------------------------------
You asked about the dependency 'androidx.activity:activity:1.8.0'.
You have been advised to add this dependency to 'implementation'.
------------------------------------------------------------

Shortest path from :app to androidx.activity:activity:1.8.0 for releaseCompileClasspath:
:app
\--- com.google.android.material:material:1.13.0-alpha12
\--- androidx.activity:activity:1.8.0

Shortest path from :app to androidx.activity:activity:1.8.0 for releaseRuntimeClasspath:
:app
\--- com.google.android.material:material:1.13.0-alpha12
\--- androidx.activity:activity:1.8.0

Source: release, main
---------------------
* Uses 9 classes, 5 of which are shown: androidx.activity.OnBackPressedCallback, androidx.activity.OnBackPressedDispatcher, androidx.activity.result.ActivityResult, androidx.activity.result.ActivityResultCallback, androidx.activity.result.ActivityResultLauncher (implies implementation).
* Provides 1 lint registry: # (implies implementation).
```
**Describe the bug**
A module in my Android Studio Kotlin project has the following dependency:
```
dependencies {
...
implementation("com.google.android.material:material:1.13.0-alpha12")
...
}
```
`./gradlew buildHealth` produces the following output:
```
Advice for :app
These transitive dependencies should be declared directly:
implementation("androidx.activity:activity:1.8.0")
```
If this dependency is only used by `com.google.android.material:material`, then why should I declare it directly?

**To Reproduce**
I suppose, any project with this particular dependency would cause this problem.

**Expected behavior**
No advice on declaring the dependency directly should be produced.

**Additional context**
The project code is not publicly available yet, so I can't provide any links.

**NOTE**
Exactly similar problems exist in my project for the following dependencies:

`androidx.appcompat:appcompat:1.7.0` \ `androidx.lifecycle:lifecycle-common:2.8.7`

`androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7` \ `androidx.lifecycle:lifecycle-viewmodel:2.8.7`

`androidx.test.ext:junit:1.2.1` \ `androidx.test:monitor:1.7.1`

`androidx.test.ext:junit:1.2.1` \ `junit:junit:4.13.2`

`androidx.test.espresso:espresso-core:3.6.1` \ `androidx.test:runner:1.6.1`

`androidx.test.espresso:espresso-core:3.6.1` \ `org.hamcrest:hamcrest-core:1.3`

`com.google.android.material:material:1.13.0-alpha12` \ `androidx.annotation:annotation:1.8.1`

`com.google.android.material:material:1.13.0-alpha12` \ `androidx.coordinatorlayout:coordinatorlayout:1.1.0`

`com.google.android.material:material:1.13.0-alpha12` \ `androidx.fragment:fragment:1.5.4`

`com.google.android.material:material:1.13.0-alpha12`\ `androidx.lifecycle:lifecycle-livedata-core:2.8.7`

`com.google.android.material:material:1.13.0-alpha12` \ `androidx.viewpager2:viewpager2:1.1.0-beta02`

`com.google.android.play:app-update:2.1.0` ->`com.google.android.gms:play-services-tasks:18.0.2`

`com.google.dagger:dagger:2.56.1` \ `javax.inject:javax.inject:1`

`com.journeyapps:zxing-android-embedded:4.3.0` \ `com.google.zxing:core:3.4.1`

`com.louiscad.splitties:splitties-views:3.0.0` \ `com.louiscad.splitties:splitties-resources:3.0.0`

`com.louiscad.splitties:splitties-views:3.0.0` \ `com.louiscad.splitties:splitties-systemservices:3.0.0`

`dev.chrisbanes.insetter:insetter:0.6.1` \ `androidx.core:core:1.16.0`

`org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2` \ `org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2`

Contributor guide

Open the contributing guide

Research direction

Reproduce the report with an Android project using the listed dependency declarations, then run ./gradlew buildHealth and the :app:reason task to compare the advice with the dependency paths and usage details. The issue is done when the incorrect direct-dependency advice is no longer produced and the reason output has the requested section order and explanatory narrative.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.