android / codelab-android-dagger

Apache License 2.0
181 stars 157 forks source link

In section, Subcomponents, Tutorial doesn't show, explicitly, removal of registration component injectors from AppComponent #52

Open dgoldhirsch opened 3 years ago

dgoldhirsch commented 3 years ago

This paragraph is stated (truthfully): In AppComponent, we have to remove the methods that can inject registration view classes because these won't be used anymore, those classes will use the RegistrationComponent.

But, it'd be helpful to the student to be told explicitly to remove these lines from AppComponent:

    fun inject(activity: RegistrationActivity)
    fun inject(fragment: EnterDetailsFragment)
    fun inject(fragment: TermsAndConditionsFragment)

Furthermore, it'd probably be helpful to add a gotcha warning in the next section of the tutorial ("Scoping Subcomponents"), warning them that if they failed to remove those injector calls from AppComponent they will get this error:

/Users/dg891e/repos/googlecodelabs/android-dagger/app/build/tmp/kapt3/stubs/debug/com/example/android/dagger/di/AppComponent.java:8: error: [Dagger/IncompatiblyScopedBindings] com.example.android.dagger.di.AppComponent scoped with @Singleton may not reference bindings with different scopes:
public abstract interface AppComponent {
                ^
      @com.example.android.dagger.di.ActivityScope class com.example.android.dagger.registration.RegistrationViewModel
rickyManalo commented 3 years ago

I was losing my mind because I can't see why I was getting that error. The codelab do need to make this changes