I've just released <v3.3.0 of the Dependency Analy...
# community-news
t
🙌 2
🚀 5
thank you 2
With 3.3.0, DAGP has improved handling of runtime classpaths. It will suggest adding
runtimeOnly
dependencies that would otherwise be removed if you followed advice to remove another dependency that had been transitively providing it. It considers dependencies to have "runtime-only capabilities" if they use some well-known java or android features like service providers or content providers (etc), or if they contain classes that are accessed via reflection (
Class.forName("...")
) by something else on the compile classpath. I think this is an improvement, but note that upgrades to 3.3.0 might generate new advice when you thought you had already fully satisfied all of DAGP's requirements 😅 For some context, I originally started working on this feature after observing deployment failures for Cash backend services, since the JVM relies heavily on these runtime techniques—often implicitly (meaning without documentation). Those Cash services compiled fine but failed at runtime in various ways.
c
I get the runtimeOnly suggestion on my dependency of kotlinx.coroutines.android I haven't made the switch because I don't full understand the suggestion and wanted to make sure it wasn't a false positive. is there something inherent about kotlinx.coroutines.android that makes it a runtimeOnly dep?
t
you can check with the
reason
task. Paste the output of the suggestion you're seeing here, please
c
Copy code
./gradlew mysdk:reason --id org.jetbrains.kotlinx:kotlinx-coroutines-android
Configuration on demand is an incubating feature.

> Configure project :
> Task :mysdk:reason

------------------------------------------------------------
You asked about the dependency 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2 (libs.kotlinx.coroutines.android)'.
You have been advised to change this dependency to 'runtimeOnly' from 'implementation'.
------------------------------------------------------------

Shortest path from :mysdk to org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2 (libs.kotlinx.coroutines.android) for debugCompileClasspath:
:mysdk
\--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2

Shortest path from :mysdk to org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2 (libs.kotlinx.coroutines.android) for debugRuntimeClasspath:
:mysdk
\--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2

Shortest path from :mysdk to org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2 (libs.kotlinx.coroutines.android) for debugUnitTestCompileClasspath:
:mysdk
\--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2

Shortest path from :mysdk to org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2 (libs.kotlinx.coroutines.android) for debugUnitTestRuntimeClasspath:
:mysdk
\--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2

Shortest path from :mysdk to org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2 (libs.kotlinx.coroutines.android) for debugAndroidTestCompileClasspath:
:mysdk
\--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2

Shortest path from :mysdk to org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2 (libs.kotlinx.coroutines.android) for debugAndroidTestRuntimeClasspath:
:mysdk
\--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2

Shortest path from :mysdk to org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2 (libs.kotlinx.coroutines.android) for releaseCompileClasspath:
:mysdk
\--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2

Shortest path from :mysdk to org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2 (libs.kotlinx.coroutines.android) for releaseRuntimeClasspath:
:mysdk
\--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2

Shortest path from :mysdk to org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2 (libs.kotlinx.coroutines.android) for releaseUnitTestCompileClasspath:
:mysdk
\--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2

Shortest path from :mysdk to org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2 (libs.kotlinx.coroutines.android) for releaseUnitTestRuntimeClasspath:
:mysdk
\--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2

Source: debug, android_test
---------------------------
* Provides 2 service loaders: kotlinx.coroutines.android.AndroidDispatcherFactory, kotlinx.coroutines.android.AndroidExceptionPreHandler (implies testRuntimeOnly).

Source: debug, main
-------------------
* Provides 2 service loaders: kotlinx.coroutines.android.AndroidDispatcherFactory, kotlinx.coroutines.android.AndroidExceptionPreHandler (implies runtimeOnly).

Source: debug, test
-------------------
* Provides 2 service loaders: kotlinx.coroutines.android.AndroidDispatcherFactory, kotlinx.coroutines.android.AndroidExceptionPreHandler (implies testRuntimeOnly).

Source: release, main
---------------------
* Provides 2 service loaders: kotlinx.coroutines.android.AndroidDispatcherFactory, kotlinx.coroutines.android.AndroidExceptionPreHandler (implies runtimeOnly).

Source: release, test
---------------------
* Provides 2 service loaders: kotlinx.coroutines.android.AndroidDispatcherFactory, kotlinx.coroutines.android.AndroidExceptionPreHandler (implies testRuntimeOnly).


BUILD SUCCESSFUL in 821ms
183 actionable tasks: 1 executed, 182 up-to-date
t
so it's this line:
Copy code
* Provides 2 service loaders: kotlinx.coroutines.android.AndroidDispatcherFactory, kotlinx.coroutines.android.AndroidExceptionPreHandler (implies runtimeOnly).
You must not actually be using any of the classes (symbols) from that dependency at compile-time
also this:
Copy code
You have been advised to change this dependency to 'runtimeOnly' from 'implementation'.
Basically you don't need it on
implementation
because you don't have to compile against it. But because it has these service loaders, DAGP can't safely recommend you fully remove it, as there might be some runtime access
c
Interesting. i wonder if i can actually just remove that depdnency completely... recompile and then see if it still compiles fine
t
The output from
buildHealth
probably says you can either remove it or move it to runtimeOnly 👍
❤️ 1