Dagger and databinding

Viewed 3429

I have a MVVM project where I have ViewModel classes extending BaseObservable. Now if put @Inject class in my ViewModel then compilation fails with many errors like: "error: package xxx.databinding does not exist"

Can I find the actual error that's causing this using some gradle technique? Also is @Inject really supported with databinding?

Edit:

Code is exactly the same as https://github.com/googlesamples/android-architecture/tree/todo-mvvm-databinding/

In that I have added dagger and I'm trying to @Inject a repository into a view model that extends BaseObservable. As soon as I add @Inject into the view model then I cant compile

3 Answers

Like Uli mentioned, this is due to the number of displayed errors being limited by the compiler.

Do this:

1. Increase the displayed error limit by doing the following

Add this snippet in your submodule gradle file inside the android block.

kapt {
    javacOptions {
        // Increase the max count of errors from annotation processors.
        // Default is 100.
        option("-Xmaxerrs", 1000)
    }
}

2. Find the errors which are not binding related and fix them.

i.e (Fix the errors from app/src/.. folders and ignore the ones from app/build/generated/.. which are binding related)

Check this thread and this comment for more info.

Related