Issue
I'm trying to make multi module project with Dagger2. You can see my code following the link. In the main branch is working solution where all the dagger classes are in presentation module.
Now I'm trying to make separate app module for the DI root. You can see the latest attempts in the develop branch. It's not working. I want to make my root ApplicationComponent component in app module and add there PresentationComponent (sub)component from other module. Every time I try something, eventually I get following:
dagger.internal.codegen.ComponentProcessor was unable to process 'ru.ircover.schultetables.app.ApplicationComponent' because not all of its dependencies could be resolved. Check for compilation errors or a circular dependency with generated code
It's very strange as I didn't change any dependencies in comparison with main branch. The only thing changed - new link from root component ApplicationComponent to child PresentationComponent. As I understand it, there is no way to appear circular dependency as app module and its content is not visible in presentation module. I've followed all the tutorials I've met in google, but none of them helped.
What I've already tried:
- Add to root component getter of subcomponent.
- Add to root component
BuilderorFactoryof subcomponent. - Add to root component special module with
subcomponentlink. - Move
injectmethods of child component to the parent.
Now I'm stuck. It seems that the problem is somewhere in components or modules connection, but I can't manage to find where and how it happened. I need help here.
Solution
I've managed to build your project with these changes:
- To the left is a presentation, to the right is an app, as you can see, I've removed dagger-android, AND make moxy deps as API (because your app is a main module, it has to see all deps to build a graph), or you can just add moxy deps to the app

- and after that, there won't be any dagger warning, but you need to fix some of your files to complete the build. Btw, to pass something to module's constructor is a bad and deprecated practice. As you can see in PresentationModule I removed constructor and removed provideContext. And I moved a Context binding to the ApplicationComponent - it is the good and right place to do it.

- And I also removed constructor parameter from PresentationComponent.Factory.create

Answered By - Grigoriym
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.