← Android app
APK·Guide
All tools

Android packages

An .apk is a ZIP archive: classes*.dex (the code), AndroidManifest.xml and res/ (binary XML), resources.arsc, native libraries in lib/<abi>/, assets/, and signatures. The tool reads only the directory and the signing block up front; the code is a library you can reuse.

Contents

  1. Signatures
  2. App Bundles
  3. The APK library
  4. The AppFrameworks library

1Signatures

ZIP entrieslocal headers + data
APK Signing Blocku64 size · ID-value pairs · u64 size · "APK Sig Block 42"
central directory
end record

The tool reads the signers, their certificates, algorithms and content digests. It doesn't verify them: apksigner verify --print-certs app.apk does.

2App Bundles

An .aab is the upload format for Google Play: one folder per module (base/, feature modules), each with manifest/AndroidManifest.xml, dex/ and res/, plus BundleConfig.pb. The manifest and resources are aapt2 protobuf rather than binary XML; the AXML tool reads both.

3The APK library

lib/apk.js is a JavaScript module with no user interface. It exports the class ApkPackage and reads the archive with lib/compression/zip.js, which it imports itself. Read the certificates with lib/x509.js (Certificates guide) and the manifest with lib/axml.js (AXML guide).

import { ApkPackage } from "../lib/apk.js";
import { X509Certificate } from "../lib/x509.js";

const apk = await ApkPackage.open(file);
console.log(apk.schemes);                         // ["v1", "v2", "v3"]
for (const signer of apk.signers) {
	console.log(signer.scheme, signer.signatureAlgorithms.map(ApkPackage.algorithmName), signer.certificates.length);
	console.log(new X509Certificate(signer.certificates[0]).subject.text);
}
const dex = await apk.archive.read("classes.dex");
Method / propertyWhat it does
await ApkPackage.open(fileOrBlob)Opens the package (reading only the ZIP directory, the signing block and the v1 signature names) and returns an ApkPackage.
apk.archiveThe ZIP archive (a ZipArchive of lib/compression/zip.js).
apk.signingBlock{ offset, size } of the APK Signing Block, or null.
apk.blocksIts ID-value pairs: [{ id, name, size }] (v2, v3, v3.1, verity padding, source stamps, Play metadata…).
apk.signers[{ scheme, certificates, signatureAlgorithms, digests: [{ algorithm, hex }], publicKey, minSdk, maxSdk }]. Certificates are DER, the leaf first.
apk.schemesThe schemes present, among "v1", "v2", "v3", "v3.1".
apk.v1FilesThe v1 signature files' names.
apk.summary{ files, size, compressedSize, dexFiles, resources, assets, metaInf, arscSize, hasManifest, librariesByAbi }.
apk.bundleModulesThe modules of an App Bundle, or [].
apk.errorsProblems found; the rest is still usable.
ApkPackage.algorithmName(id)A signature or digest algorithm ID's name (0x0103 → RSASSA-PKCS1v1.5 SHA-256).
ApkPackage.BLOCK, ApkPackage.BLOCK_NAMES, ApkPackage.SIGNATURE_ALGORITHMSThe known block IDs ({ v2, v3, v31, verityPadding }), their names, and the algorithm IDs.

4The AppFrameworks library

lib/app-frameworks.js is a JavaScript module with no user interface. It exports the class AppFrameworks, which recognises cross-platform frameworks in APKs and IPAs from their file names and summarises their configuration files; it reads binary XML with lib/axml.js and plists with lib/plist.js, which it imports itself (Cordova's text config.xml needs the browser's DOMParser). The APK and IPA tools show its results in their Frameworks section (common/frameworks.js, FrameworksSection).

import { AppFrameworks } from "../lib/app-frameworks.js";

const names = apk.archive.entries.map((entry) => entry.name);
for (const framework of AppFrameworks.detect(names, "android")) {
	console.log(framework.name, framework.chips, framework.evidence);
	for (const config of framework.configs) {
		const summary = await AppFrameworks.summarize(config.kind, await apk.archive.read(config.name));
		console.log(config.name, summary.rows);
	}
}
MethodWhat it does
AppFrameworks.detect(names, platform)[{ id, name, chips, about, evidence, code: [{ name, label }], configs: [{ name, kind }], web, manifestMetadata }]. names are relative to the APK root, or to the app bundle for iOS ("ios"). Recognises React Native, Expo, Capacitor, Cordova, Flutter, .NET, Unity, NativeScript, Godot, Qt, Unreal and Cocos.
await AppFrameworks.summarize(kind, bytes){ rows: [[key, value, warning]], lists: [{ title, items, warning }], notes } for a configuration file: capacitor.config.json, Cordova's config.xml (text or binary) and plugin list, Expo manifests and Expo.plist, Flutter's asset manifest and licence notices, .env files, package.json, the Unity version. Warnings point out what matters for security (remote start pages, wildcard origins, debuggable WebViews, keys in config).
AppFrameworks.manifestMetadata(manifestBytes, pattern)The <meta-data> entries of a binary AndroidManifest.xml whose names match.
AppFrameworks.bundleKind(firstBytes)"Hermes bytecode v96" or "plain JavaScript bundle", from a bundle's first 12 bytes.