Dexguard 使用混淆了 Attributeset 中的 Android 模式

Dexguard usage obfuscates Android schema in Attributeset

我有一个 Android 项目,我需要在其中提取创建 TextView 时的 android:textStyle 值。我通过在 AttributeSet 上调用以下内容来执行此操作:

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

这给了我正确的 textStyle 值,在 xml 中设置,而我没有使用 Dexguard。一旦我混淆了代码,这段代码将始终 return 默认值 0.

我还没有找到具体的解释或推理来解释为什么会发生这种情况。因此,我们将不胜感激任何和所有合理的答案。

事实证明 Dexguard 确实混淆了 XML 属性名称,因此引用 'textStyle' 无效。

通过将以下内容添加到规则集中,这不再是一个问题

-keepresourcexmlattributenames **/textStyle

这也可以用于将通配符 (**) 替换为正确的 XML 层次结构路径。