1 # AAPT2 On-Disk Formats 2 - AAPT2 Container Format (extension `.apc`) 3 - AAPT2 Static Library Format (extension `.sapk`) 4 5 ## AAPT2 Container Format (extension `.apc`) 6 The APC format (AAPT2 Container Format) is generated by AAPT2 during the compile phase and 7 consumed by the AAPT2 link phase. It is a simple container format for storing compiled PNGs, 8 binary and protobuf XML, and intermediate protobuf resource tables. It also stores all associated 9 meta-data from the compile phase. 10 11 ### Format 12 The 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 20 This is followed by `entry_count` of the following data structure. It must be aligned on a 32-bit 21 boundary, 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)`. | 26 | `8` | `entry_length` | The length of the data that follows. | 27 | `entry_length` | `data` | The payload. The contents of this varies based on the `entry_type`. | 28 29 If the `entry_type` is equal to `RES_TABLE (0x00000000)`, the `data` field contains a serialized 30 [aapt.pb.ResourceTable](Resources.proto). 31 32 If the `entry_type` is equal to `RES_FILE (0x00000001)`, the `data` field contains the following: 33 34 35 | 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` | `padding` | Up to 4 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 43 ## AAPT2 Static Library Format (extension `.sapk`) 44 45