ButterKnife inject views in Fragment

I’ve lost a lot of time to figure it out. I had in onCreateView() in my Fragment:

 ButterKnife.inject(this, rootView);

and it wasn’t working (nullpointerexception), so I was testing what’s wrong and could not fixed it, because it looked allright. And the solution is simple as always. This is the solution for Android Studio (for Eclipse check this)

Open File -> Settings (ctrl + alt + s). Navigate to Compiler -> Annotation Processors and at the top of the window check the Enable annotation processing. That’s it.


Leave a Reply

Your email address will not be published. Required fields are marked *