Android: Why do we need to use R2 instead of R with butterknife?

后端 未结 1 1629
庸人自扰
庸人自扰 2021-01-12 04:04

I\'ve been using butterknife for a few months and I\'ve just noticed in its documentation that it says:

Now make sure you use R2 instead of R inside a

相关标签:
1条回答
  • 2021-01-12 04:58

    Using R2 is only necessary for building Android Library projects.

    https://github.com/JakeWharton/butterknife#library-projects

    It has to do with fact that the values in the R.java generated class aren't declared as "final" when built as part of a library. The annotations used for @BindView() need these R. values to be final and not subject to change later on.

    I'm sure someone could explain all of this better -- but the bottom line is - you're just fine using "R." values in @BindView in an Android application

    0 讨论(0)
提交回复
热议问题