$ show iBotPeaches/Apktool
Apktool is a command-line tool for reverse engineering Android APK files. It decodes binary resources (resources.arsc, AndroidManifest.xml, 9-patch images) back to nearly original form, disassembles DEX bytecode into Smali assembly using baksmali, and provides a rebuild pipeline that reassembles and signs the APK via aapt2 and apksigner. The tool manages Android framework APK installations to resolve resource references during decoding. The architecture is a multi-module Gradle project: a core library (apktool-lib) exposing programmatic APIs (ApkDecoder, ApkBuilder, ResTable, Framework), and a CLI wrapper (apktool-cli) that provides commands like decode, build, install-framework, and list-frameworks. Supporting libraries (brut.j.util, brut.j.dir, brut.j.yaml, brut.j.xml) handle I/O, directory abstraction, YAML metadata, and XML serialization. External dependencies include Google's aapt2 binary (bundled per platform) and the smali/baksmali libraries for DEX compilation. The codebase demonstrates deep knowledge of Android binary formats, with custom parsers for chunked resource tables, binary XML, and resource qualifiers, and includes extensive regression tests covering edge cases and security vulnerabilities.
The LLM identified 4 files worth highlighting for reuse:
A lightweight, reusable thread pool that submits tasks (Callable) and waits for all to complete, propagating the first exception via an AtomicReference. It does not depend on any internal project code beyond a simple interface, making it trivially extractable to any Java project that needs parallel work with fail-fast semantics.
An endian-aware DataInputStream wrapper that reads little-endian integers, shorts, longs, floats, and arrays with optional bounds checking. It provides robust skip logic and can read null-terminated ASCII or UTF-16 strings. This is a general-purpose utility for any project that needs to parse binary file formats with custom endianness.
An interface and abstract implementation for uniform access to hierarchical directories, supporting file/directory entry listing, reading, and recursive copying. Concrete implementations cover the local filesystem (FileDirectory) and ZIP archives (ZipRODirectory). The abstraction is clean, self-contained (only depends on Java standard library), and can be reused in any project that needs to treat directories and ZIP files interchangeably.
A comprehensive parser and serializer for Android resource configuration qualifiers (language, region, screen density, orientation, BCP47 variants, etc.). It handles all known qualifier types, generates the canonical qualifier string, and supports comparison. While domain-specific to Android, it is the most complete open-source implementation of Android resource config parsing and could be reused in any Android tooling project.