0

I have an Android project where I need to extract the android:textStyle values on TextView creation. I do this by calling the following on the AttributeSet:

attrs.getAttributeIntValue("http://schemas.android.com/apk/res/android", "textStyle", 0);

This gives me the correct textStyle values, set in xml, while I am not using Dexguard. As soon as I obfuscate the code this code piece will always return the default value 0.

I have yet to find a concrete explanation, or reasoning, that might explain why this is happening. So any and all reasonable answers would be appreciated.

Hrafn
  • 2,867
  • 3
  • 25
  • 44

1 Answers1

1

Turns out Dexguard does obfuscate XML attribute names, and thus referencing 'textStyle' wasn't working.

By adding the following to the rule set this stopped being a problem

-keepresourcexmlattributenames **/textStyle

This could also be used with replacing the wilcards (**) with the proper XML hierarchy path.

Hrafn
  • 2,867
  • 3
  • 25
  • 44