编译时错误,无法找到DataBinding包

时间:2018-01-03 11:51:12

标签: android android-databinding dagger

我正在使用数据绑定和dagger 2进行DI,一切都很完美。然后我重构了我的代码以使用android dagger 2.11。现在由于某种原因数据绑定搞砸了。

我收到此错误。None of my dating classes seem to work

我做错了什么。 项目无法编译

MusicServiceApplication.java

public class MusicServiceApplication extends Application implements HasActivityInjector{
private AppComponent component;

public static MusicServiceApplication get(Activity activity){
    return (MusicServiceApplication) activity.getApplication();
}

@Inject
DispatchingAndroidInjector<Activity> activityDispatchingAndroidInjector;


@Override
public void onCreate() {
    super.onCreate();
    initDagger();
}

public MusicServiceApplication() {
}

private void initDagger() {
    component = DaggerAppComponent.builder()
            .application(this)
            .build()
            .inject(this);
}

public AppComponent getDaggerAppComponent (){
    return  component;
}

@Override
public AndroidInjector<Activity> activityInjector() {
    return activityDispatchingAndroidInjector;
    }
}

ActivityBuilder.java

 @Module
public abstract class ActivityBuilder {

    @Binds
    @IntoMap
    @ActivityKey(MainActivity.class)
    abstract AndroidInjector.Factory<? extends Activity> bindMainActivity(HomeActivityComponent.Builder builder);
    }

AppComponent.java

    @Singleton
@Component(modules = {AndroidSupportInjectionModule.class,MusicServiceModule.class, ViewIdentifierModule.class,ActivityBuilder.class})
public interface AppComponent  {

    void inject(MusicServiceApplication musicServiceApplication);

    @Component.Builder
    interface Builder {
        @BindsInstance
        Builder application(Application application);
        AppComponent build();
       }
    }

ExoplayerModule.java

 Module(includes = HomeActivityModule.class)
public abstract class ExoplayerModule {

/*    String streamUrl;
    String categoryType;*/
    private static final DefaultBandwidthMeter defaultBandwidthMeter = new DefaultBandwidthMeter();;

    public ExoplayerModule() {
    }

    @Provides
    @HomeActivityScope
    public SimpleExoPlayer getSimpleExoplayer(Context context){
        SimpleExoPlayer player;
        TrackSelection.Factory adaptiveTrackSelectionFactory =
                new AdaptiveTrackSelection.Factory(defaultBandwidthMeter);
        // using a DefaultTrackSelector with an adaptive video selection factory

        player = ExoPlayerFactory.newSimpleInstance(
                new DefaultRenderersFactory(context),
                new         DefaultTrackSelector(adaptiveTrackSelectionFactory),
                new DefaultLoadControl());

        return player;

    }


}

FragmentBuilder.java

  @Module
abstract class FragmentBuilder {
    @Binds
    @IntoMap
    @FragmentKey(CategoryListFragment.class)
    abstract AndroidInjector.Factory<? extends Fragment> bindCategoryListFragmentInjectorFactory(CategoryListFragmentComponent.Builder builder);

    @Binds
    @IntoMap
    @FragmentKey(CategoryDetailFragment.class)
    abstract AndroidInjector.Factory<? extends Fragment> bindCategoryDetailFragmentInjectorFactory(CategoryDetailFragmentComponent.Builder builder);


    @Binds
    @IntoMap
    @FragmentKey(StartFragment.class)
    abstract AndroidInjector.Factory<? extends Fragment> bindStartComponentInjectorFactory(StartComponent.Builder builder);

    @Binds
    @IntoMap
    @FragmentKey(AboutFragment.class)
    abstract AndroidInjector.Factory<? extends Fragment> bindAboutComponentInjectorFactory(AboutComponent.Builder builder);

}

HomeActivityComponent.java

 @Subcomponent(modules = {HomeActivityModule.class, FragmentBuilder.class})
public interface HomeActivityComponent extends AndroidInjector<MainActivity> {
    @Subcomponent.Builder
    abstract class Builder extends AndroidInjector.Builder<MainActivity>{}
}

HomeActivityModule.java

@Module(subcomponents = {CategoryListFragmentComponent.class, CategoryDetailFragmentComponent.class,AboutComponent.class,StartComponent.class})
public class HomeActivityModule {

    private Activity activityContext;

    public HomeActivityModule(Activity activityContext) {
        this.activityContext = activityContext;
    }

    @Provides
    @HomeActivityScope
    public Context getActivtyContext(){
        return activityContext;
    }
}

0 个答案:

没有答案