# aaptjs3

> Node.js wrapper for Android Asset Packaging Tool 2 (aapt2), bundled with prebuilt binaries for Windows, macOS, and Linux.

Latest version **2.0.2** (published 2026-07-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install aaptjs3
pnpm add aaptjs3
yarn add aaptjs3
bun add aaptjs3
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; large bundle.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2026-07-20 |
| First published | 2021-04-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 21.5 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | kiliaosi |
| Maintainers | kiliaosi |
| Keywords | aapt2, aapt, aaptjs, node-aapt, apktool, android, apk-resolve |

## Links

- npm: https://www.npmjs.com/package/aaptjs3
- Repository: https://github.com/kiliaosi/aaptjs3
- Homepage: https://github.com/kiliaosi/aaptjs3#readme
- Issues: https://github.com/kiliaosi/aaptjs3/issues
- npm.io page: https://npm.io/package/aaptjs3

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 2.0.2 (latest) — 2026-07-20
- 2.0.1 — 2026-06-02
- 2.0.0 — 2026-06-02
- 1.0.9 — 2026-06-02
- 1.0.8 — 2026-06-02
- 1.0.6 — 2021-04-19
- 1.0.5 — 2021-04-14
- 1.0.4 — 2021-04-14
- 1.0.3 — 2021-04-13
- 1.0.2 — 2021-04-13
- 1.0.1 — 2021-04-13
- 1.0.0 — 2021-04-13

## README

# aaptjs3

Node.js wrapper for **[aapt2](https://developer.android.com/tools/aapt2)** (Android Asset Packaging Tool 2). Bundles prebuilt aapt2 binaries — no Android SDK installation required.

> **v2.0.0** upgrades from aapt1 to aapt2. If you need aapt1, use `aaptjs3@^1.0.9` or the `legacy-aapt1` branch.

## Platform Support

| Platform | Architecture | Status |
|----------|-------------|--------|
| Windows  | x64         | ✅     |
| macOS    | x64 / ARM64 | ✅     |
| Linux    | x64         | ✅     |

The bundled macOS executable is a universal binary shared by x64 and ARM64.
Node.js 18 or newer is required.

## Install

```bash
npm install aaptjs3 --save
```

## Quick Start

```js
const aapt = require('aaptjs3');

// Dump APK metadata
const { stdout } = await aapt.dump('app.apk', 'badging');
console.log(stdout);

// Get structured APK info
const info = await aapt.getApkInfo('app.apk');
// { package: 'com.example.app', version: '1.0.0',
//   name: 'My App', icon: 'res/mipmap/ic_launcher.png' }

// List APK contents
const { stdout: files } = await aapt.list('app.apk');
```

## Custom Binary

Configure your own aapt binary — version auto-detected:

```js
const aapt = require('aaptjs3');

// Use a custom aapt binary
await aapt.configure({ binPath: '/path/to/custom/aapt' });

// If the path is broken or version can't be detected,
// falls back to built-in aapt2 with a warning.
```

## API

```typescript
interface ExecResult {
  stdout: string;
  stderr: string;
}

interface PackageInfo {
  package: string;
  version: string;
  name: string;
  icon: string;
}
```

### `configure(opts: { binPath?: string }): Promise<void>`

Configure a custom aapt binary. Version is auto-detected. All subsequent API calls use the configured binary. If the path is invalid or version unknown, falls back to built-in aapt2.

### `getBinPath(): string`

Returns the currently active aapt binary path.

### `getVersion(): 0 | 1 | 2`

Returns the detected version of the active binary. Compare it with `VERSION.AAPT1` or `VERSION.AAPT2`.

### `aapt(commandArgs: string[], maxBuffer?: number): Promise<ExecResult>`

Low-level execution of the active aapt binary with arbitrary arguments.

### `dump(apkPath: string, value: string, extraArgs?: string[]): Promise<ExecResult>`

Dump APK information. Supported subcommands: `badging`, `strings`, `resources`, `permissions`, `configurations`, `packagename`, `styleparents`, `apc`, `overlayable`, `chunks`, `xmltree`, `xmlstrings`.

```js
// Simple dumping
await aapt.dump('app.apk', 'badging');
await aapt.dump('app.apk', 'permissions');
await aapt.dump('app.apk', 'packagename');

// xmltree/xmlstrings need --file flag
await aapt.dump('app.apk', 'xmltree', ['--file', 'AndroidManifest.xml']);
```

### `list(apkPath: string): Promise<ExecResult>`

List APK contents. In aapt2 mode, reads the ZIP central directory directly.

### `getApkInfo(apkPath: string): Promise<PackageInfo>`

Extract package name, version, app label, and icon.

### Deprecated APIs (aapt1 only)

These throw errors in default aapt2 mode. They work only if you configure a custom aapt1 binary:

| Function | aapt2 Replacement |
|----------|------------------|
| `packageCmd()` | `aapt2 compile` + `aapt2 link` |
| `remove()` | `aapt2 optimize` or zip tools |
| `add()` | `aapt2 compile` + `aapt2 link` |
| `crunch()` | `aapt2 compile` |
| `singleCrunch()` | `aapt2 compile` |

## Migration from v1.x

| v1.x | v2.x |
|------|------|
| `dump(apk, value)` | Same, or `dump(apk, value, extraArgs)` |
| `list(apk, args)` | `list(apk)` — args ignored, reads ZIP |
| `getApkInfo(apk)` | Same |
| `packageCmd()` | ❌ Throws |
| `remove()` / `add()` | ❌ Throws |
| `crunch()` / `singleCrunch()` | ❌ Throws |

## License

The JavaScript wrapper is MIT licensed. The bundled Google AAPT2 binaries are
distributed under their original licenses; see `THIRD_PARTY_NOTICES`.

---
_Source: https://npm.io/package/aaptjs3 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
