Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decompiling .xsd file in res/xml folder Issue #1952

Closed
AliMehrpour opened this issue Dec 5, 2018 · 6 comments · Fixed by #1973

Comments

@AliMehrpour
Copy link

commented Dec 5, 2018

Information

  1. Apktool Version (apktool -version) - v2.3.4
  2. Operating System (Mac, Linux, Windows) - Mac
  3. APK From? (Playstore, ROM, Other) - Own apk

Stacktrace/Logcat

I: Using Apktool 2.4.0-3cf5cb-SNAPSHOT
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether resources has changed...
I: Building resources...
S: WARNING: Could not write to (/var/root/Library/apktool/framework), using /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/ instead...
S: Please be aware this is a volatile directory and frameworks could go missing, please utilize --frame-path if the default storage directory is unavailable
W: /Users/amehrpour/Development/Android/apk/WTXF/res/values/xmls.xml:3: error: Resource entry ww_box_styles_schema is already defined.
W: res/xml/ww_box_styles_schema.xsd:0: Originally defined here.
W:
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/brut_util_Jar_7077972587209156129.tmp, p, --forced-package-id, 127, --min-sdk-version, 18, --target-sdk-version, 28, --version-code, 2018082112, --version-name, 3.11.0, --no-version-vectors, -F, /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/APKTOOL7940613748200716848.tmp, -0, arsc, -0, assets/clients_branch, -0, assets/tmp_fragment, -0, png, -0, 
res/drawable-hdpi-v4/abc_ab_share_pack_mtrl_alpha.9.png, -0, 
res/drawable-hdpi-v4/abc_btn_switch_to_on_mtrl_00001.9.png, -0, 
res/drawable-hdpi-v4/abc_btn_switch_to_on_mtrl_00012.9.png, -0, 
res/drawable-hdpi-v4/abc_cab_background_top_mtrl_alpha.9.png, -0, 
res/drawable-hdpi-v4/abc_list_divider_mtrl_alpha.9.png, -0, 
res/drawable-hdpi-v4/abc_list_focused_holo.9.png, -0, 
res/drawable-hdpi-v4/abc_list_longpressed_holo.9.png, -0, 
res/drawable-hdpi-v4/abc_list_pressed_holo_dark.9.png, -0, 
res/drawable-hdpi-v4/abc_list_pressed_holo_light.9.png, -0, res/drawable-hdpi-v4/abc_list_selector_disabled_holo_dark.9.png, -0, res/drawable-hdpi-v4/abc_list_selector_disabled_holo_light.9.png, -0, res/drawable-hdpi-v4/abc_menu_hardkey_panel_mtrl_mult.9.png, -0, res/drawable-hdpi-v4/abc_popup_background_mtrl_mult.9.png, -0, res/drawable-hdpi-v4/abc_scrubber_primary_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/abc_scrubber_track_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-hdpi-v4/abc_switch_track_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/abc_tab_indicator_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/abc_textfield_activated_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/abc_textfield_default_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/abc_textfield_search_activated_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/abc_textfield_search_default_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/com_facebook_tooltip_black_background.9.png, -0, res/drawable-hdpi-v4/com_facebook_tooltip_blue_background.9.png, -0, res/drawable-hdpi-v4/common_google_signin_btn_icon_dark_normal_background.9.png, -0, res/drawable-hdpi-v4/common_google_signin_btn_icon_light_normal_background.9.png, -0, res/drawable-hdpi-v4/common_google_signin_btn_text_dark_normal_background.9.png, -0, res/drawable-hdpi-v4/common_google_signin_btn_text_light_normal_background.9.png, -0, res/drawable-hdpi-v4/notification_bg_low_normal.9.png, -0, res/drawable-hdpi-v4/notification_bg_low_pressed.9.png, -0, res/drawable-hdpi-v4/notification_bg_normal.9.png, -0, res/drawable-hdpi-v4/notification_bg_normal_pressed.9.png, -0, res/drawable-ldrtl-hdpi-v17/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-ldrtl-mdpi-v17/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-ldrtl-xhdpi-v17/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-ldrtl-xxhdpi-v17/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-ldrtl-xxxhdpi-v17/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-mdpi-v4/abc_ab_share_pack_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_btn_switch_to_on_mtrl_00001.9.png, -0, res/drawable-mdpi-v4/abc_btn_switch_to_on_mtrl_00012.9.png, -0, res/drawable-mdpi-v4/abc_cab_background_top_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_list_divider_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_list_focused_holo.9.png, -0, res/drawable-mdpi-v4/abc_list_longpressed_holo.9.png, -0, res/drawable-mdpi-v4/abc_list_pressed_holo_dark.9.png, -0, res/drawable-mdpi-v4/abc_list_pressed_holo_light.9.png, -0, res/drawable-mdpi-v4/abc_list_selector_disabled_holo_dark.9.png, -0, res/drawable-mdpi-v4/abc_list_selector_disabled_holo_light.9.png, -0, res/drawable-mdpi-v4/abc_menu_hardkey_panel_mtrl_mult.9.png, -0, res/drawable-mdpi-v4/abc_popup_background_mtrl_mult.9.png, -0, res/drawable-mdpi-v4/abc_scrubber_primary_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_scrubber_track_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-mdpi-v4/abc_switch_track_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_tab_indicator_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_textfield_activated_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_textfield_default_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_textfield_search_activated_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_textfield_search_default_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/com_facebook_tooltip_black_background.9.png, -0, res/drawable-mdpi-v4/com_facebook_tooltip_blue_background.9.png, -0, res/drawable-mdpi-v4/common_google_signin_btn_icon_dark_normal_background.9.png, -0, res/drawable-mdpi-v4/common_google_signin_btn_icon_light_normal_background.9.png, -0, res/drawable-mdpi-v4/common_google_signin_btn_text_dark_normal_background.9.png, -0, res/drawable-mdpi-v4/common_google_signin_btn_text_light_normal_background.9.png, -0, res/drawable-mdpi-v4/notification_bg_low_normal.9.png, -0, res/drawable-mdpi-v4/notification_bg_low_pressed.9.png, -0, res/drawable-mdpi-v4/notification_bg_normal.9.png, -0, res/drawable-mdpi-v4/notification_bg_normal_pressed.9.png, -0, res/drawable-xhdpi-v4/abc_ab_share_pack_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_btn_switch_to_on_mtrl_00001.9.png, -0, res/drawable-xhdpi-v4/abc_btn_switch_to_on_mtrl_00012.9.png, -0, res/drawable-xhdpi-v4/abc_cab_background_top_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_list_divider_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_list_focused_holo.9.png, -0, res/drawable-xhdpi-v4/abc_list_longpressed_holo.9.png, -0, res/drawable-xhdpi-v4/abc_list_pressed_holo_dark.9.png, -0, res/drawable-xhdpi-v4/abc_list_pressed_holo_light.9.png, -0, res/drawable-xhdpi-v4/abc_list_selector_disabled_holo_dark.9.png, -0, res/drawable-xhdpi-v4/abc_list_selector_disabled_holo_light.9.png, -0, res/drawable-xhdpi-v4/abc_menu_hardkey_panel_mtrl_mult.9.png, -0, res/drawable-xhdpi-v4/abc_popup_background_mtrl_mult.9.png, -0, res/drawable-xhdpi-v4/abc_scrubber_primary_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_scrubber_track_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_switch_track_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_tab_indicator_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_textfield_activated_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_textfield_default_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_textfield_search_activated_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_textfield_search_default_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/com_facebook_tooltip_black_background.9.png, -0, res/drawable-xhdpi-v4/com_facebook_tooltip_blue_background.9.png, -0, res/drawable-xhdpi-v4/common_google_signin_btn_icon_dark_normal_background.9.png, -0, res/drawable-xhdpi-v4/common_google_signin_btn_icon_light_normal_background.9.png, -0, res/drawable-xhdpi-v4/common_google_signin_btn_text_dark_normal_background.9.png, -0, res/drawable-xhdpi-v4/common_google_signin_btn_text_light_normal_background.9.png, -0, res/drawable-xhdpi-v4/frn_nav_item_bg_selected.9.png, -0, res/drawable-xhdpi-v4/notification_bg_low_normal.9.png, -0, res/drawable-xhdpi-v4/notification_bg_low_pressed.9.png, -0, res/drawable-xhdpi-v4/notification_bg_normal.9.png, -0, res/drawable-xhdpi-v4/notification_bg_normal_pressed.9.png, -0, res/drawable-xxhdpi-v4/abc_ab_share_pack_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_btn_switch_to_on_mtrl_00001.9.png, -0, res/drawable-xxhdpi-v4/abc_btn_switch_to_on_mtrl_00012.9.png, -0, res/drawable-xxhdpi-v4/abc_cab_background_top_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_list_divider_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_list_focused_holo.9.png, -0, res/drawable-xxhdpi-v4/abc_list_longpressed_holo.9.png, -0, res/drawable-xxhdpi-v4/abc_list_pressed_holo_dark.9.png, -0, res/drawable-xxhdpi-v4/abc_list_pressed_holo_light.9.png, -0, res/drawable-xxhdpi-v4/abc_list_selector_disabled_holo_dark.9.png, -0, res/drawable-xxhdpi-v4/abc_list_selector_disabled_holo_light.9.png, -0, res/drawable-xxhdpi-v4/abc_menu_hardkey_panel_mtrl_mult.9.png, -0, res/drawable-xxhdpi-v4/abc_popup_background_mtrl_mult.9.png, -0, res/drawable-xxhdpi-v4/abc_scrubber_primary_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_scrubber_track_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_switch_track_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_tab_indicator_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_textfield_activated_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_textfield_default_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_textfield_search_activated_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_textfield_search_default_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/common_google_signin_btn_icon_dark_normal_background.9.png, -0, res/drawable-xxhdpi-v4/common_google_signin_btn_icon_light_normal_background.9.png, -0, res/drawable-xxhdpi-v4/common_google_signin_btn_text_dark_normal_background.9.png, -0, res/drawable-xxhdpi-v4/common_google_signin_btn_text_light_normal_background.9.png, -0, res/drawable-xxxhdpi-v4/abc_btn_switch_to_on_mtrl_00001.9.png, -0, res/drawable-xxxhdpi-v4/abc_btn_switch_to_on_mtrl_00012.9.png, -0, res/drawable-xxxhdpi-v4/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-xxxhdpi-v4/abc_switch_track_mtrl_alpha.9.png, -0, res/drawable-xxxhdpi-v4/abc_tab_indicator_mtrl_alpha.9.png, -0, arsc, -I, /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/1.apk, -S, /Users/amehrpour/Development/Android/apk/WTXF/res, -M, 
/Users/amehrpour/Development/Android/apk/WTXF/AndroidManifest.xml]

Steps to Reproduce

  1. apktool d XYZ.apk
  2. apktool b XYZ

APK

If this APK can be freely shared, please upload/attach a link to it.

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? Yes
  2. If you are trying to install a modified apk, did you resign it? N/A
  3. Are you using the latest apktool version? 2.3.4

@AliMehrpour AliMehrpour changed the title Apktool issue with 9.png files? Decompiling .xsd file in res/xml folder Issue Dec 6, 2018

@AliMehrpour

This comment has been minimized.

Copy link
Author

commented Dec 6, 2018

After diging into the source code, I've figured out the ResFileDecoder couldn't decode res/xml/file.xsd file! the file type is xml and need to be decoded with raw decoder. So after changing ResFileDecoder to decode the file, it worked fine

@iBotPeaches

This comment has been minimized.

Copy link
Owner

commented Dec 27, 2018

Thanks for the research. Do you have an application? Or should I write a test with just an XSD file in the /res/xml location?

@AliMehrpour

This comment has been minimized.

Copy link
Author

commented Dec 28, 2018

Yeah, you can just have an XSD file in /res/xml location.

@iBotPeaches

This comment has been minimized.

Copy link
Owner

commented Jan 4, 2019

There are a few issues going on here and I'm not sure yet.

If you place an XSD file in res/xml/foo.xsd, then rebuild with aapt1 or aapt2 you get different results. aapt1 compiles the file down to AXML, so when you decode it (with apktool), we run the XML decoder over the file to return it to XML (XSD). In the terms of aapt2, well this.

➜  Desktop aapt d xmltree aapt1-build.apk res/xml/ww_box_styles_schema.xsd
N: xs=http://www.w3.org/2001/XMLSchema
  E: xs:schema (line=2)
    E: xs:element (line=3)
      A: name="test" (Raw: "test")
      E: xs:complexType (line=4)
        E: xs:sequence (line=5)
          E: xs:element (line=6)
            A: name="person" (Raw: "person")
            A: type="xs:string" (Raw: "xs:string")
          E: xs:element (line=7)
            A: name="address" (Raw: "address")
            E: xs:complexType (line=8)
              E: xs:sequence (line=9)
                E: xs:element (line=10)
                  A: name="name" (Raw: "name")
                  A: type="xs:string" (Raw: "xs:string")
                E: xs:element (line=11)
                  A: name="address" (Raw: "address")
                  A: type="xs:string" (Raw: "xs:string")
                E: xs:element (line=12)
                  A: name="city" (Raw: "city")
                  A: type="xs:string" (Raw: "xs:string")
                E: xs:element (line=13)
                  A: name="country" (Raw: "country")
                  A: type="xs:string" (Raw: "xs:string")
➜  Desktop aapt d xmltree aapt2-build.apk res/xml/ww_box_styles_schema.xsd
W/asset   (18436): Asset path aapt2-build.apk is neither a directory nor file (type=1).
ERROR: dump failed because assets could not be loaded

So Apktool will have to be patched to attempt a decode of xsd files, and if it fails attempt a raw copy. This might break more things than I want, so will keep it on master for a bit and see if any eager builders notice anything wrong.

@iBotPeaches

This comment has been minimized.

Copy link
Owner

commented Jan 4, 2019

Pull request attached, and bug opened at AOSP for more information - https://issuetracker.google.com/issues/122321161

@AliMehrpour

This comment has been minimized.

Copy link
Author

commented Jan 6, 2019

👍🏼

iBotPeaches added a commit that referenced this issue Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.