google/dagger

DaggerAppComponent not creating in the version 2.51.1

jesphinpt opened this issue · 3 comments

I have updated the dagger from the version 2.17 to 2.51.1. both the version not creating the DaggerAppComponent

error: cannot find symbol
import com.app.appscreens.auth.signup.DaggerSignupComponent;
                                                             ^

My Code


@Module
public class SignupModule {

    private AppCompatActivity mActivity;
    public SignupModule(AppCompatActivity activity) {
        this.mActivity = activity;
    }

    @Provides
    AppCompatActivity providesActivity() {
        return mActivity;
    }


    @Provides
    @CustomScopes.AuthScope
    SignupContract.Presenter providesPresenter(SignupPresenter presenter) {
        return presenter;
    }

    @Provides
    @CustomScopes.AuthScope
    CompositeDisposable providesCompositeDisposable() {
        return new CompositeDisposable();
    }
}

In activity:

private SignupComponent mComponent;


     mComponent = DaggerSignupComponent.builder()
              .workoutAppComponent(((WorkoutApplication) getApplicationContext()).getWorkoutAppComponent())
             .signupModule(new SignupModule(this))
             .build();

 public SignupComponent getComponent() {
     return mComponent;
 }



Hi, do you have code for SignupComponent? Did you use @Component annotation on it? that is required for generating Component.

@wanyingd1996 Yes, I am using the annotation @Component. Also, my issue is due to the id is not known in the activity files. So it shows the error in the component as well. Any doc to add the dagger in a step-by-steps will be helpful

my issue is due to the id is not known

Can you clarify what is id? DaggerSignupComponent is a generated by Dagger, so if it is missing, it is usually the annotation not being setup correctly. There are several issues in your Module file.

(1) A dagger module should not have constructor. Dagger generate classes references provides method and other methods within the module statically, we won't call the customized constructor
(2) Provides method should be a static.

Please refer to dagger tutorial https://dagger.dev/dev-guide/, to understand the standard setup for dagger to make things work.