Mortar-architect icon indicating copy to clipboard operation
Mortar-architect copied to clipboard

Qualifier annotations passed in constructor not carried over to the modules/components

Open vpratfr opened this issue 8 years ago • 0 comments

Hi,

I have a presenter which looks like that:

@AutoStackable(
        component = @AutoComponent(
                includes = StandardAutoComponent.class
        ),
        pathWithView = PickDeviceView.class
)
@DaggerScope(PickDevicePresenter.class)
public class PickDevicePresenter extends ViewPresenter<PickDeviceView> {

    EventBus globalEventBus;
    Context activityContext;
    Detector detector;

    @Inject
    public PickDevicePresenter(@ForActivity Context activityContext, @ForApplication EventBus globalEventBus) {
        this.activityContext = activityContext;
        this.globalEventBus = globalEventBus;
        this.detector = new BluetoothLeDetector(activityContext, globalEventBus);
    }

// ...

Generated module in the PickDeviceStackable class:

  @dagger.Module
  public class Module {
    @Provides
    @DaggerScope(PickDevicePresenter.class)
    public PickDevicePresenter providesPresenter(Context activityContext, EventBus globalEventBus) {
      return new PickDevicePresenter(activityContext, globalEventBus);
    }
  }

Dagger error:

Error:(18, 8) error: android.content.Context cannot be provided without an @Provides-annotated method.
com.marvinlabs.horserider.ui.view.PickDeviceView.presenter
[injected field of type: com.marvinlabs.horserider.presenter.PickDevicePresenter presenter]
com.marvinlabs.horserider.presenter.stackable.PickDeviceStackable.Module.providesPresenter(android.content.Context activityContext, de.greenrobot.event.EventBus globalEventBus)
[parameter: android.content.Context activityContext]

This is because the generated code should also have the @ForActivity annotations.

I had already mentionned a similar issue in auto-dagger2: https://github.com/lukaspili/Auto-Dagger2/issues/3

Currently this is preventing the application to even compile.

vpratfr avatar Jul 31 '15 13:07 vpratfr