I'm learning ButterKnife and dagger and came to know that Butterknife only helps to avoid boilerplate codes(Binding views) and it doesn't really inject. And dagger compliment Butterknife in this case as it injects code. Now what is the difference between Binding views and Injecting views?
Butterknife - Binding views: It binds the view from XML layout to a Java member variable. So you don't have to call findViewById
manually to bind the views.
Dagger - dependency injection library, to inject dependencies:
Dependency Injection, in simple terms, means that you pass (inject) the dependencies to any class rather than creating the dependency inside the class itself.
Say, you have a class called ClassA which requires an instance of ClassB. One way is you can create the instance of ClassB inside the Class A itself. But in dependency injection, we create the ClassB instance outside and pass it to ClassA either through its constructor or a setter method.
Dependency injection can be done without any framework but it gets ugly if you have a large project and it has lots of complicated dependencies. Dagger is an Android framework which helps to do dependency injection in a cleaner way.