It works as expected as long as the module has no platform dependencies.
For example, I run it as ./gradlew --init-script=E:\Work\Projects\Sample\init.gradle :app:resolveDebugUnitTestCompileDependencies and the output is something like:
* What went wrong:
Execution failed for task ':app:resolveDebugUnitTestCompileDependencies'.
> Could not resolve all files for configuration ':app:resolvableDebugUnitTestCompileClasspath'.
> Could not find com.google.firebase:firebase-analytics:.
Required by:
project :app
> Could not find com.google.firebase:firebase-config:.
Required by:
project :app
How do I fix this? I need to resolve all dependencies of a module variant.
Thanks!
However, resolving dependencies doesn’t work and gives the same error. ./gradlew --init-script=E:\Work\Projects\Sample\init.gradle :app:resolveDebugUnitTestRuntimeDependencies
fails with:
Execution failed for task ':app:resolveDebugUnitTestRuntimeDependencies'.
> Could not resolve all files for configuration ':app:resolvableDebugUnitTestRuntimeClasspath'.
> Could not find com.google.firebase:firebase-analytics:.
Required by:
project :app
Can you show an MCVE where it can compile but your task fails?
Because it should not compile.
The idiomatic way is to also have implementation(platform("com.google.firebase:firebase-bom:33.2.0")) in app.
If utils is a library you can make the platform api instead of implementation as it then leaks into the consumer compile classpath and thus can be used from there. But usually it is bad practice to use transitive dependencies and api should only be used for things in your - well - API like return types, parameter types, superclasses, …
For constraints like a platform it is less problematic but still might be a bit unclean.
If it is about not declaring the version multiple times, I’d strongly recommend a version catalog.
If you execute ./gradlew :app:compileDebugAndroidTestJavaWithJavac or ./gradlew :app:dependencies you see that those are also failing to resolve the same.