Skip to content

refactor: new BinaryXmlResourceParser, ResXmlSerializer and more#4077

Merged
IgorEisberg merged 1 commit into
mainfrom
xml-refactor
Jan 28, 2026
Merged

refactor: new BinaryXmlResourceParser, ResXmlSerializer and more#4077
IgorEisberg merged 1 commit into
mainfrom
xml-refactor

Conversation

@IgorEisberg
Copy link
Copy Markdown
Collaborator

@IgorEisberg IgorEisberg commented Jan 28, 2026

Describing this PR fully is like writing a novel, so I'll sum up the main changes. Most of the code has comments and notes anyway, especially on sensitive/confusing parts.

  • A new BinaryXmlResourceParser fully powered by ResChunkPullParser. Some obfuscated APKs that couldn't be decoded properly are now easily decoded.
  • ResXmlSerializer replaces MXSerializer. It's a stripped-down and customized version of KXmlSerializer (used in AOSP) that's made specifically for safely writing resource XML files.
  • ResStringEncoder (accompanied by brut.util.TextUtils) handles most of the encoding and escaping of strings. The value of ResString can now be StyledString as well, and ResStringEncoder handles the spans properly according to StyledString rules. The encoder uses the same StringBuilder through the whole process without allocating any substrings, much lower overhead than prior methods.
  • literals.xml has been expanded to demonstrate the new capabilities of the smart escaping algorithm.
  • Added --ignore-raw-values advanced option. The only APK that uses the --keep-raw-values aapt2 option that I know of is CarrierConfig.apk that preserves MCC/MNC raw values. Not used much in normal production.
  • Cleared up a lot of boilerplate code.
  • android.* code removed, most of it was unused. The used parts merged into code where they are relevant. This will prevent breaking conflicts for people who use Apktool as a library along with AOSP code.
  • Silenced some warnings about uninteresting stuff like dummy chunks or padding added by obfuscators.

Tested on large scale. Let me know if there are any questions.

@IgorEisberg IgorEisberg enabled auto-merge (squash) January 28, 2026 00:38
Copy link
Copy Markdown
Owner

@iBotPeaches iBotPeaches left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. Debian would love to hear that android.content.* is removed

@IgorEisberg IgorEisberg merged commit be8f7e7 into main Jan 28, 2026
18 checks passed
@IgorEisberg IgorEisberg deleted the xml-refactor branch January 28, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants