this is an extension of Android: Why do we need to use R2 instead of R with butterknife? and Reference in R.java not final
I understand that fields of R.java in the library project do not have final modifier to protect value collisions between library projects. However ButterKnife recovers final modifier in R2 and uses it.
I think this goes to the collision problem and values can collide, but there is no problem. How does it work?
===
I add examples. There are one main project and one library project. The main project has com.main.R and the library project has com.library.R.
- When there is a collision:
- com.main.R: public static final int example = 0x1234
- com.library.R: public static int example = 0x1234
if build tools does not recompile the library project, how can we avoid the collision between those values?
- When ButterKnife creates R2
- com.main.R: public static final int example = 0x1234
- com.library.R: public static int example = 0x1234
- com.library.R2: public static final int example = 0x1234
com.library.R2 has a collision and even it has a final modifier. Doesn't it produce a problem? why?
Thanks
R.java
anymore. Refer this tools.android.com/tips/non-constant-fields – Border