Link in R.java is not final

When creating a link for the styled attribute in the generation of the R.java file, something seems to be wrong.

One would expect the field declaration to be final , but it is not. Why?

RES / values ​​/ attrs.xml

 <?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="MyTextView"> <attr name="typeface" format="string"/> </declare-styleable> </resources> 

GEN / com.example / R.java

  /** <p>This symbol is the offset where the {@link com.example.R.attr#typeface} attribute value can be found in the {@link #MyTextView} array. <p>Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character. <p>This may also be a reference to a resource (in the form "<code>@[<i>package</i>: <i>type</i>:<i>name</i></code>") or theme attribute (in the form "<code>?[<i>package</i>: [<i>type</i>:]<i>name</i></code>") containing a value of this type. @attr name com.example:typeface */ public static int MyTextView_typeface = 0; 
+1
source share
1 answer

The links inside R.java are not final since a couple of years ago.

The reason for this is that the generated identifiers may collide if you had several library projects that your main project depends on.

Here is another explanation: http://tools.android.com/tips/non-constant-fields

+3
source

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


All Articles