2

In our project we've just started using Google's Errorprone (http://errorprone.info/) to get additional checks during compile time.

I've managed to eradicate all remaining warnings we had in our project, but am Stuck with a warning generated within a ViewBinding class that is generated by ButterKnife. To be exact, the issue arises because I've created a custom view that uses generics to allow it to work on different Number types.

class MyCustomView<T extends Number> {
    ...
}

Within the XML layout file, an instance of that view is placed without the chosen number type, as it's not possible there afaik. Then, within one of our fragments, I just get a reference to that view with ButterKnife:

@BindView(R.id.customview)
protected MyCustomView<Integer> customView;

When running errorprone, this results in the following warning:

Warning:(42, 59) [unchecked] unchecked conversion
required: MyCustomView<Integer>
found:    MyCustomView

I fully understand what this warning means, but I don't see a way of getting rid of it without having to remove the generics in the custom view. Annotating the member field in the fragment with a @SuppressWarnings annotations didn't help either.

So I am wondering if anybody has an idea on how to solve this? Can I disable the checks in generated code somehow? Or just on files that containg "ViewBinding" in its name? Or does ButterKnife maybe need to make some adaptions to allow Errorprone to ignore these warnings?

I would be glad for any help! Thanks!

florianbaethge
  • 2,520
  • 3
  • 22
  • 29

0 Answers0