Skip to content

@Named annotations in constructor #7

Description

@peppered

Hi!
I'm using Architect-Robot and it seems that Auto-Dagger2 doesn't handle @Named arguments. E.g. I have the following class (with multiple Scheduler arguments):

@AutoStackable(
        component = @AutoComponent(includes = FromActivityAutoComponent.class),
        pathWithView = SignUpView.class
)
@AutoExpose
@DaggerScope(SignUpPresenter.class)
public class SignUpPresenter extends ViewPresenter<SignUpView> {

    private AccountManager accountManager;
    private Scheduler ioScheduler;
    private Scheduler mainScheduler;

    public SignUpPresenter(AccountManager accountManager, @Named("scheduler.io") Scheduler ioScheduler, @Named("scheduler.main") Scheduler mainScheduler) {
        this.accountManager = accountManager;
        this.ioScheduler = ioScheduler;
        this.mainScheduler = mainScheduler;
    }
}

During the build I get the following error:

Error:(19, 8) error: rx.Scheduler cannot be provided without an @Provides-annotated method.
architect.commons.view.PresentedLinearLayout.presenter
[injected field of type: ui.signup.SignUpPresenter presenter]
ui.signup.stackable.SignUpStackable.Module.providesPresenter(services.AccountManager accountManager, rx.Scheduler ioScheduler, rx.Scheduler mainScheduler)
[parameter: rx.Scheduler ioScheduler]

And I found that generated module looks as follows (without @Named annotations)

@dagger.Module
public class Module {
  @Provides
  @DaggerScope(SignUpPresenter.class)
  public SignUpPresenter providesPresenter(AccountManager accountManager, Scheduler ioScheduler, Scheduler mainScheduler) {
    return new SignUpPresenter(accountManager, ioScheduler, mainScheduler);
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions