Make resource shrinking able to handle style resource parent references that start with 'style/' instead of the more strict '@style/'. AAPT will handle either format, so the resource shrinker should as well to prevent build failures that only occur when shrinking.
MOS_MIGRATED_REVID=147849301
@@ -30,6 +30,7 @@ import static com.android.SdkConstants.FD_RES_VALUES;
import static com.android.SdkConstants.PREFIX_ANDROID;
import static com.android.SdkConstants.PREFIX_RESOURCE_REF;
import static com.android.SdkConstants.PREFIX_THEME_REF;
+import static com.android.SdkConstants.REFERENCE_STYLE;
import static com.android.SdkConstants.STYLE_RESOURCE_PREFIX;
import static com.android.SdkConstants.TAG_ITEM;
import static com.android.SdkConstants.TAG_RESOURCES;
@@ -1356,8 +1357,16 @@ public class ResourceUsageAnalyzer {
} else if (!parent.isEmpty()) {
String parentStyle = parent;
if (!parentStyle.startsWith(STYLE_RESOURCE_PREFIX)) {
+ // Fix (see method comment): allow parent references to start with 'style/'
+ // as well as the more strict '@style/'.
+ // TODO(apell): Remove handling of 'style/' references when no longer supported
+ // by AAPT.
+ if (parentStyle.startsWith(REFERENCE_STYLE)) {
+ parentStyle = "@" + parentStyle;
+ } else {
parentStyle = STYLE_RESOURCE_PREFIX + parentStyle;
}
+ }
Resource ps = getResourceFromUrl(LintUtils.getFieldName(parentStyle));
if (ps != null && definition != null) {
// Fix (see method comment): don't create parent to child reference.
