title: Module in Module Dagger: This module is public, but it includes non-public (or effectively non-public) modules
body: <p>I am using Dagger 2 for DI and want to inject one Module (module A) inside another one (module B). I am not including module A in any component or anywhere else.</p>
  <p>My code looks like this:</p>
  <pre><code>@Module 
  public class ModuleA {
  
      @Provides
      @Singleton
      @Named(&quot;classA&quot;)
      public ClassA classA() {
          return new ClassA();
      }
  }
  </code></pre>
  <pre><code>@Module(includes = ModuleA.class)
  public class ModuleB {
  
      @Provides
      @Singleton
      public ClassB classB(@Named(&quot;classA&quot;) ClassA classA) {
          return new ClassB(classA);
      }
  }
  </code></pre>
  <p>I am getting the following error:</p>
  <pre><code>ModuleB.java:18: error: This module is public, but it includes non-public (or effectively non-public) modules. Either reduce the visibility of this module or make ModuleA public.
  public class ModuleB {
         ^
  </code></pre>
  <p>I need ModuleB to be public because I am injecting it in a Component which is in a different package, so the only option is to make ModuleA public, but it is already public.</p>
  <p>How to solve this issue? Also, since I am new to Dagger DI, let me know if I am not following some best practice or if I can make my code better.</p>