skylot / jadx

Dex to Java decompiler
Apache License 2.0
41.81k stars 4.88k forks source link

Deobfuscation of declare-styleable in attrs.xml #247

Closed kismeter closed 4 years ago

kismeter commented 6 years ago

there's declare-styleable in attrs.xml, when decompiled, the declare-styleable is not recoginzed, only attrs

bagipro commented 4 years ago

Please attach a test apk and reopen the issue

swearl commented 1 year ago

here is my code

in jadx

R

public final class R {
    public static final class styleable {
        public static final int StrokeTextView_gradientOrientation = 0x00000002;
        public static final int StrokeTextView_strokeColor = 0x00000000;
        public static final int StrokeTextView_strokeWidth = 0x00000001;
        public static final int UISwitch_bmHeight = 0x00000001;
        public static final int UISwitch_bmWidth = 0x00000000;
        public static final int UISwitch_sliderHeight = 0x00000003;
        public static final int UISwitch_sliderWidth = 0x00000002;
        public static final int[] StrokeTextView = {R.attr.strokeColor, R.attr.strokeWidth, R.attr.gradientOrientation};
        public static final int[] UISwitch = {R.attr.bmWidth, R.attr.bmHeight, R.attr.sliderWidth, R.attr.sliderHeight};
    }
}

attr.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <attr name="bmWidth" format="dimension">
    </attr>
    <attr name="bmHeight" format="dimension">
    </attr>
    <attr name="sliderWidth" format="dimension">
    </attr>
    <attr name="sliderHeight" format="dimension">
    </attr>
    <attr name="strokeColor" format="color">
    </attr>
    <attr name="strokeWidth" format="dimension">
    </attr>
    <attr name="gradientOrientation">
        <enum name="horizontal" value="0" />
        <enum name="vertical" value="1" />
    </attr>
</resources>

i think the correct code is

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="StrokeTextView">
        <attr name="strokeColor" format="color" />
        <attr name="strokeWidth" format="dimension" />
        <attr name="gradientOrientation">
            <enum name="horizontal" value="0" />
            <enum name="vertical" value="1" />
        </attr>
    </declare-styleable>
    <declare-styleable name="UISwitch">
        <attr name="bmWidth" format="dimension" />
        <attr name="bmHeight" format="dimension" />
        <attr name="sliderWidth" format="dimension" />
        <attr name="sliderHeight" format="dimension" />
    </declare-styleable>
</resources>
jpstotz commented 1 year ago

@swearl Please provide a sample APK so we can reproduce the problem. Without an APK, it is unlikely we can fix this problem.