Manifest
Represents parsed AndroidManifest.xml information.
Overview
The Manifest class provides access to the parsed AndroidManifest.xml file, including package information, version, permissions, and application metadata.
import { Apk } from "node-apk";
const apk = new Apk("app.apk");
const manifest = await apk.getManifestInfo();Properties
package
readonly package: stringThe unique package identifier for the application.
Example
console.log(`Package: ${manifest.package}`);
// Output: Package: com.example.myappversionCode
readonly versionCode: numberThe internal version number. This value is used by the system to determine which version is newer.
Example
console.log(`Version Code: ${manifest.versionCode}`);
// Output: Version Code: 42versionName
readonly versionName: stringThe version name shown to users.
Example
console.log(`Version: ${manifest.versionName}`);
// Output: Version: 2.5.1applicationLabel
readonly applicationLabel: string | numberThe application label. This can be either:
- A
stringif the label is hardcoded - A
number(resource ID) if the label references a string resource
Example
const label = manifest.applicationLabel;
if (typeof label === "number") {
// Resolve from resources
const resources = await apk.getResources();
const resolved = resources.resolve(label);
console.log(`App Name: ${resolved[0]?.value}`);
} else {
console.log(`App Name: ${label}`);
}TIP
Use apk.getLabel() to automatically resolve the label from resources.
applicationIcon
readonly applicationIcon: numberThe resource ID of the application icon.
Example
const resources = await apk.getResources();
const iconResources = resources.resolve(manifest.applicationIcon);
for (const res of iconResources) {
console.log(`Icon: ${res.value} (${res.locale?.language})`);
}TIP
Use apk.getLauncherIcon() to extract the icon directly.
permissions
readonly permissions: Iterable<string>An iterable of all permissions required by the application.
Example
console.log("Permissions:");
for (const permission of manifest.permissions) {
console.log(` - ${permission}`);
}
// Output:
// Permissions:
// - android.permission.INTERNET
// - android.permission.CAMERA
// - android.permission.ACCESS_FINE_LOCATIONConvert to array:
const permsArray = [...manifest.permissions];
console.log(`Total permissions: ${permsArray.length}`);receivers
readonly receivers: Iterable<Receiver>An iterable of all broadcast receivers declared in the manifest.
Example
for (const receiver of manifest.receivers) {
console.log(`Receiver: ${receiver.name}`);
console.log(` Permission: ${receiver.permission}`);
console.log(` Exported: ${receiver.exported}`);
}raw
readonly raw: XmlElementThe raw binary XML element tree. Use this for properties without built-in accessors.
Example
// Access raw XML structure
console.log(JSON.stringify(manifest.raw, null, 2));
// Access specific elements
const activities = manifest.raw.children["activity"];
for (const activity of activities ?? []) {
console.log(`Activity: ${activity.attributes["name"]}`);
}Receiver Class
Represents a broadcast receiver from the manifest.
Properties
class Receiver {
readonly name: string; // Class name of the receiver
readonly permission: string; // Required permission (may be undefined)
readonly exported: boolean; // Whether the receiver is exported
readonly raw: XmlElement; // Raw XML element
}Example
for (const receiver of manifest.receivers) {
if (receiver.exported) {
console.log(`Exported receiver: ${receiver.name}`);
if (receiver.permission) {
console.log(` Requires: ${receiver.permission}`);
}
}
}Complete Example
import { Apk } from "node-apk";
async function analyzeApk(path: string) {
const apk = new Apk(path);
const manifest = await apk.getManifestInfo();
console.log("=== APK Information ===");
console.log(`Package: ${manifest.package}`);
console.log(`Version: ${manifest.versionName} (${manifest.versionCode})`);
console.log("\n=== Permissions ===");
const permissions = [...manifest.permissions];
console.log(`Total: ${permissions.length}`);
for (const perm of permissions) {
console.log(` - ${perm}`);
}
console.log("\n=== Receivers ===");
for (const receiver of manifest.receivers) {
console.log(` ${receiver.name}`);
if (receiver.exported) {
console.log(` ⚠️ Exported`);
}
}
// Use raw access for custom elements
console.log("\n=== Activities ===");
const activities = manifest.raw.children["activity"] ?? [];
console.log(`Total: ${activities.length}`);
}
analyzeApk("app.apk");Related
- Apk - Main APK parser class
- XmlElement - Raw XML access
- Resources - Resolve resource IDs