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

I have been using butterknife for several months, and I just noticed in my documentation that it says:

Now make sure you use R2 instead of R inside the entire Butter Knife annotation.

Why? I use R and everything works fine.

+6
source share
1 answer

Using R2 is only necessary for creating Android library projects.

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

This is because the values ​​in the generated R.java class are not declared as "final" when built as part of the library. The annotations used for @BindView () require that these R. values ​​be final and not subject to change later.

I am sure that someone can explain all this better, but in the end - you just use "R." just fine values ​​in @BindView app in Android app

+9
source

Source: https://habr.com/ru/post/1015133/


All Articles