我一直在关注来自谷歌的 GithubBrowserSample 作为我的参考。我刚刚通过实施到我的 MainActivity 中对匕首进行了最后的润色,现在收到以下错误。除了包含我已经拥有的内容之外,似乎无法在其中找到太多内容。error: [Dagger/MissingBinding] [dagger.android.AndroidInjector.inject(T)] java.util.Map<java.lang.String,javax.inject.Provider<dagger.android.AndroidInjector.Factory<? extends androidx.fragment.app.Fragment>>> cannot be provided without an @Provides-annotated method.java.util.Map<java.lang.String,javax.inject.Provider<dagger.android.AndroidInjector.Factory<? extends androidx.fragment.app.Fragment>>> is injected atdagger.android.DispatchingAndroidInjector.<init>(…, injectorFactoriesWithStringKeys)dagger.android.DispatchingAndroidInjector<androidx.fragment.app.Fragment> is injected atcom.crosscare.MainActivity.dispatchingAndroidInjectorcom.crosscare.MainActivity is injected atdagger.android.AndroidInjector.inject(T)component path: com.crosscare.di.AppComponent ? com.crosscare.di.MainActivityModule_ContributeMainActivity.MainActivitySubcomponent主要活动:public class MainActivity extends AppCompatActivity implements HasSupportFragmentInjector { @Inject DispatchingAndroidInjector<Fragment> dispatchingAndroidInjector; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public DispatchingAndroidInjector<Fragment> supportFragmentInjector() { return dispatchingAndroidInjector; }}应用组件:@Singleton@Component(modules = { AndroidInjectionModule.class, AppModule.class, MainActivityModule.class})public interface AppComponent { @Component.Builder interface Builder { @BindsInstance Builder application(Application application); AppComponent build(); } void inject(CrosscareApp crosscareApp);}任何建议将不胜感激。
1 回答
哆啦的时光机
TA贡献1779条经验 获得超6个赞
经过更仔细的谷歌搜索后发现了问题。
似乎对于 androidx 我需要使用 AndroidSupportInjectionModule 而不是 AndroidInjectionModule
添加回答
举报
0/150
提交
取消