fragmentDispatchingAndroidInjector while using support fragments

后端 未结 1 1496
醉梦人生
醉梦人生 2021-01-19 06:32

I\'m trying to create a simple dagger 2 application while using support v4 fragments. After I modified my application I got this strange compilation error

Er         


        
相关标签:
1条回答
  • 2021-01-19 07:18

    You need to put it in a module that you then register in your Component, but you don't have to declare it manually, as Dagger already has the AndroidInjectionModule (or AndroidSupportInjectionModule with AppCompat) which you can use.

    You can find more about the Android setup in the official documentation or see some additional information in a similar question about when you need to install the module that was asked quite recently.

    You're not showing your AppComponent, but you most likely just forgot to add the module, so you can fix your error by adding it to your component.

    // add it somehow like this
    @Component(modules = { AndroidSupportInjectionModule.class, AppModule.class })
    public interface AppComponent {
      void inject(App app);
    }
    
    0 讨论(0)
提交回复
热议问题