Created by: raviagarwal7
Problem:
Android attributes are being populated to R.java created by mini aapt like android_font
. This causes robolectric test failures. (fails to construct Robolectric resource table)
java.lang.IllegalArgumentException: Incompatible package for com.uber:attr/android_font with resId 1 to ResourceIndex with packageIdentifier 7
at org.robolectric.res.PackageResourceTable.addResource(PackageResourceTable.java:109)
at org.robolectric.res.ResourceTableFactory.addRClassValues(ResourceTableFactory.java:71)
at org.robolectric.res.ResourceTableFactory.lambda$newResourceTable$1(ResourceTableFactory.java:45)
at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:50)
at org.robolectric.res.ResourceTableFactory.newResourceTable(ResourceTableFactory.java:38)
at org.robolectric.res.ResourceMerger.buildResourceTable(ResourceMerger.java:20)
at org.robolectric.RobolectricTestRunner.getAppResourceTable(RobolectricTestRunner.java:529)
...
RootCause:
This is happening because a third party library is including android_font
in its R.txt with an integer value. The attribute is then included in the dependee's R.java generated by miniaapt.
Solution:
Don't include any attributes which starts with "0x01"
, since those should come from the android framework. Also need make RDotTxtEntry
initialization convert integers into hexdecimal strings so that the check is effective.
This only affects R.java files generated for robolectric tests and intermediatray libraries.