Open ansman opened 4 years ago
What is the solution on this problem? You mean I either app should have direct dependency (adding implementation
) on :libraryB
or :libraryA
have api
dependency on :libraryB
right?
Don't you think this solution is anti-pattern? what's the point of creating separate modules then?
You mean I either app should have direct dependency (adding implementation) on :libraryB or :libraryA have api dependency on :libraryB right?
Hi @Kshitij09, yes that's the current solution and we're looking into ways to improve this (see https://github.com/google/dagger/issues/1991#issuecomment-661245887)
Don't you think this solution is anti-pattern? what's the point of creating separate modules then?
Admittedly, the current situation is not great (which is why we're looking into ways to fix this); however, there are other benefits to modules as explained in https://github.com/google/dagger/issues/1991#issuecomment-704950480.
Any update on improving the error messages for transitive types. I recently came across the same issue, and from stack-trace it's not clear why it's happening in multi-module project.
Would also appreciate it. Currently it's for me not possible to set up end to end testing with espresso because of that problem, which I can't solve.
What is the solution on this problem? You mean I either app should have direct dependency (adding
implementation
) on:libraryB
or:libraryA
haveapi
dependency on:libraryB
right?Don't you think this solution is anti-pattern? what's the point of creating separate modules then?
Yes, even I also faced the same problem. My architecture is :app <- :usecase <- :repository <- datastore and not able add Hilt as DI in this kind of architecture at lower layer modules. According to documentation it says "The Gradle module that compiles your Application class needs to have all Hilt modules and constructor-injected classes in its transitive dependencies."
I need to do workaround as :app module should have all the dependencies of all other modules. Which I also felt it is going antipattern. :app gradle should have :usecase :repository :datastore :anyOtherFeature
If you're using Hilt (with Gradle) the solution is to use the Hilt Gradle plugin and then enable the aggregating task
in your build.gradle
modules:
hilt {
enableAggregatingTask = true
}
then ena
@bcorso Thanks for the quick resolution. It worked!! now I removed all other dependencies for ;app module. I feel Hilt documentation is misleading as first line itself says "The Gradle module that compiles your Application class needs to have all Hilt modules and constructor-injected classes in its transitive dependencies."
then ena
@bcorso Thanks for the quick resolution. It worked!! now I removed all other dependencies for ;app module. I feel Hilt documentation is misleading as first line itself says "The Gradle module that compiles your Application class needs to have all Hilt modules and constructor-injected classes in its transitive dependencies."
Really thanks! saved my day !
Does dagger2 have any flag for aggregation or is it only for hilt ?
If you're using Hilt (with Gradle) the solution is to use the Hilt Gradle plugin and then enable the
aggregating task
in yourbuild.gradle
modules:hilt { enableAggregatingTask = true }
thanks, it worked for me
Say you have 3 modules,
:app
,:libraryA
and:libraryB
.:app
depends on:libraryA
which in turn depends:libraryB
using theimplementation
configuration. If:libraryB
has some dagger modules or components you can get this cryptic error message:Running with
--stacktrace
gives slightly more information:This is of course an error in the setup and
:app
should either depend on:libraryB
directly or you should useapi
but it's very difficult to determine what module is causing issue. You see which type it related too but not really which file is being processed.In any case I think there is room improvement here.