Created by: paveldudka
It turns out that currently RDotTxtEntry
sorting logic doesn't handle one of the corner cases which produces invalid R.java.
That's basically the reason why we had bunch of test failures after we integrated #879
Consider following example:
<declare-styleable name="AnchorLayout">
<attr name="anchorInner" format="reference" />
</declare-styleable>
<declare-styleable name="AnchorLayout_Layout">
<attr name="somethingElse"/>
</declare-styleable>
This should result in something like this:
int[] styleable AnchorLayout { 0x7F010101 }
int styleable AnchorLayout_anchorInner 0
int[] styleable AnchorLayout_Layout { 0x7F010102 }
int styleable AnchorLayout_Layout_somethingElse 0
However, current sorting send AnchorLayout_anchorInner
all the way to the botton (since AnchorLayout_anchorInner
> AnchorLayout_Layout
) which breaks assumptions made in MergeAndroidResourcesStep
, so here is what we currently get:
int[] styleable AnchorLayout { }
int[] styleable AnchorLayout_Layout { 0x7F010102 }
int styleable AnchorLayout_Layout_somethingElse 0
....
int styleable AnchorLayout_anchorInner 0x7F010101
which is a complete nonesence.
Approach:
Since we need to group our styleable attributes based on their parent and it is impossible to correctly detect parent name from styleable attr name (consider something like this int styleable A_B_C 0
where it can be attr B_C
which belongs to styleable A
or attr C
which belongs to styleable A_B
:)), we decided to introduce "parent" field to styleable attributes, so it carries information about its parent, so we can properly group them.
@raviagarwal7 , since you last touched this logic, it does make sense if you are up-to-speed with these changes