Dagger 2: Provide same instance between multiple Component with same Scope on different library modules
<p>I have a Core Android Library where I'm defining a CoreComponent ad using the @Singleton scope to inject instances of classes provided by a CoreModule.</p>

<pre><code>@Singleton
@Component(modules = {CoreModule.class})
public interface CoreComponent {
    void inject(SomeClass target);
}

@Module
public class CoreModule {
    @Singleton
    @Provides
    CoreRepository provideCoreRepository() {
        return new CoreRepositoryImpl();
    }
}
</code></pre>

<p>I would like to access the same @Singleton instances from another Android Library that is depending on the Core Library and is using another component.</p>

<pre><code>@Singleton
@FooScope
@Component(modules = {CoreModule.class, FooModule.class})
public interface FooComponent {
    void inject(SomeActivity target);
}

public class FooActivity extends AppCompatActivity {
    @Inject
    public CoreRepository repo;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        injectDependencies();
        super.onCreate(savedInstanceState);
    }
    [...]
}
</code></pre>

<p>The code above builds but the @Singleton scope is "local" to the Component. In other words there are two singleton instances, one for the for the CoreComponent and one for the FooComponent.</p>

<pre><code>Android Application
├── Foo Library
|   └── Core Library
├── Bar Library
|   └── Core Library
·
·
·
└── Core Library
</code></pre>

<p>I think that the best solution should be using a Subcomponent but, unfortunately, doesn't seem possible because the Core Library has no visibility of the other libraries.</p>

<p>Is there another way to share with Dagger the same instance of one class between components if the class is annotated with the same Scope?</p>