[d] Some resource XML files are not decoded (left as root/res/alias_<hash> raw AXML)

オープン
#243 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
android, java

調査の方向性

Start from the decompile path that logs “Decoding file resources” and how layout entries in resources.arsc are mapped through path-map.json and alias_* files under root/res. Compare decoded files under resources/package_1/res/layout with the 276 layouts that stay raw AXML (e.g. res/Zy.xml / ime_inputview_root). Done when those layouts decode to XML like aapt2/apktool, or a warning is emitted when a file is skipped. Use the attached apkeditor_repro_min.apk.

索引モデルが issue の本文から書いたものです。

説明

bug

Describe the bug

Resource XML files are only partially decoded. aapt2 reports 579 layout/* resources in resources.arsc, but apkeditor d only writes 303 of them as XML under resources/package_1/res/layout/. The remaining 276 are not decoded at all — they are kept as raw (binary) files under root/res/alias_<hash> and only referenced from path-map.json and resources/package_1/res/values/layouts.xml:

resources/package_1/res/values/layouts.xml
  <layout name="ime_inputview_root">res/Zy.xml</layout>

path-map.json
  { "name": "res/Zy.xml", "alias": "res/alias_1f76152b" }

So no data is lost, but the XML is not decoded (it stays AXML). Nothing is printed on the console — it fails silently.

The set of files that do get decoded looks arbitrary: it is not split by resource-id range, not by package (there is only 0x7f), and not by "file referenced by several resources". Decoded and missing entries are interleaved.

To Reproduce

  1. Used version: 1.4.9 (apkeditor.jar, 7.61 MB)
  2. Operating system: Windows 11 x64 (the bug is in pure Java, so it should reproduce on any OS)
  3. Command:
java -jar APKEditor.jar d -i apkeditor_repro_min.apk -o out

Then check the numbers:

# resources.arsc declares 579 layout resources:
aapt2 dump resources apkeditor_repro_min.apk | grep ' layout/' | wc -l
# -> 579

# apkeditor only decoded 303 of them:
ls out/resources/package_1/res/layout | wc -l
# -> 303

# the other 276 are kept as raw AXML (not decoded):
ls out/root/res/alias_*

Log/Stacktrace

No error or warning is printed (this is the main problem — it is silent):

I: [DECOMPILE] Loading resource table...
I: [DECOMPILE] Decoding value resources...
I: [DECOMPILE] Loading resource table from file: ...\framework\1.apk
I: [DECOMPILE] Decoding file resources...
I: [DECOMPILE] Generating values XMLs...
I: [DECOMPILE] Decoding AndroidManifest.xml with resources...
I: [DECOMPILE] Copying original files...
I: [DECOMPILE] Copying assets...
I: [DECOMPILE] Copying lib...
I: [DECOMPILE] Copying unknown files...
I: [DECOMPILE] Saved to: out

Used apk file

apkeditor_repro_min.apk (1.5 MB) — attached.

It is a trimmed version of a real APK (only AndroidManifest.xml + resources.arsc + res/**; dex/assets/lib removed) and it reproduces exactly the same behaviour as the full APK. The resource table and all res/ files are byte-identical to the original.

Additional context

  • aapt2 dump xmltree apkeditor_repro_min.apk --file res/Zy.xml decodes one of the missing files fine → the file itself is a valid binary XML; it is apkeditor's decoder that skips it.
  • apkeditor d -keep-res-path shows that all res files are present (res-files/res/…) — so this is not a "file is missing from the APK" problem.
  • Examples of missing resources (all present in resources.arsc):
    layout/ime_inputview_root (res/Zy.xml), layout/layout_image_key, layout/view_candidate_list, layout/abc_action_bar_up_container, layout/ime_onehand_left, …
  • The APK uses resource path obfuscation: the files on disk are res/Zy.xml, res/GF.xml, res/-B.xml, … while the resource names in resources.arsc are intact. Maybe the decoder bails out on something in that setup (e.g. sparse type encoding / optimized table)?
  • For comparison, apktool 3.0.3 decodes all 578 entries into res/layout/ on the same APK — so the APK itself is fine.
  • Expected: all 579 layout/* resources decoded as XML (or at least a warning/error when some are skipped).

apkeditor_repro_min.zip

主要言語
Java
スター
2.3k
フォーク
417
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

REAndroid/APKEditor のほかの issue

REAndroid/APKEditor の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。