blob: 25a0e798dea29a764d377df2b9191fc06b0ea9ef [file] [log] [blame] [view]
Adam Lesinski00451162017-10-03 07:44:08 -07001# AAPT2 On-Disk Formats
2- AAPT2 Container Format (extension `.apc`)
3- AAPT2 Static Library Format (extension `.sapk`)
4
5## AAPT2 Container Format (extension `.apc`)
6The APC format (AAPT2 Container Format) is generated by AAPT2 during the compile phase and
7consumed by the AAPT2 link phase. It is a simple container format for storing compiled PNGs,
8binary and protobuf XML, and intermediate protobuf resource tables. It also stores all associated
9meta-data from the compile phase.
10
11### Format
12The file starts with a simple header. All multi-byte fields are little-endian.
13
14| Size (in bytes) | Field | Description |
15|:----------------|:--------------|:-----------------------------------------------------|
16| `4` | `magic` | The magic bytes must equal `'AAPT'` or `0x54504141`. |
17| `4` | `version` | The version of the container format. |
18| `4` | `entry_count` | The number of entries in this container. |
19
20This is followed by `entry_count` of the following data structure. It must be aligned on a 32-bit
21boundary, so if a previous entry ends unaligned, padding must be inserted.
22
23| Size (in bytes) | Field | Description |
24|:----------------|:---------------|:----------------------------------------------------------------------------------------------------------|
25| `4` | `entry_type` | The type of the entry. This can be one of two types: `RES_TABLE (0x00000000)` or `RES_FILE (0x00000001)`. |
Donald Chai6f613872019-10-19 13:38:52 -070026| `8` | `entry_length` | The length of the data that follows. Do not use if `entry_type` is `RES_FILE`; this value may be wrong. |
Adam Lesinski00451162017-10-03 07:44:08 -070027| `entry_length` | `data` | The payload. The contents of this varies based on the `entry_type`. |
28
29If the `entry_type` is equal to `RES_TABLE (0x00000000)`, the `data` field contains a serialized
30[aapt.pb.ResourceTable](Resources.proto).
31
32If the `entry_type` is equal to `RES_FILE (0x00000001)`, the `data` field contains the following:
33
34
Donald Chai6f613872019-10-19 13:38:52 -070035| Size (in bytes) | Field | Description |
36|:----------------|:-----------------|:----------------------------------------------------------------------------------------------------------|
37| `4` | `header_size` | The size of the `header` field. |
38| `8` | `data_size` | The size of the `data` field. |
39| `header_size` | `header` | The serialized Protobuf message [aapt.pb.internal.CompiledFile](ResourcesInternal.proto). |
40| `x` | `header_padding` | Up to 3 bytes of zeros, if padding is necessary to align the `data` field on a 32-bit boundary. |
41| `data_size` | `data` | The payload, which is determined by the `type` field in the `aapt.pb.internal.CompiledFile`. This can be a PNG file, binary XML, or [aapt.pb.XmlNode](Resources.proto). |
42| `y` | `data_padding` | Up to 3 bytes of zeros, if `data_size` is not a multiple of 4. |
Adam Lesinski00451162017-10-03 07:44:08 -070043
44## AAPT2 Static Library Format (extension `.sapk`)
45