aapt(1)
โจ NAME โจ
okay bestie, this is aapt (Android Asset Packaging Tool) ๐ aka the tool that packages up your Android resources so your app can actually use them ๐
๐ง SYNOPSIS ๐ง
Here's the basic vibe for every command:
aapt command [ options ] files ...
Now let's check out each command, starting with list ๐
aapt l[ist] [-v] [-a] file.{zip,jar,apk}
Peek inside a Zip-compatible archive and see what's in there ๐ฆ
aapt d[ump] [--values] WHAT file.{apk} [asset [asset ...]]
dump has a bunch of WHAT options, and each one gives you a different slice of the APK ๐
stringsโ prints the contents of the resource table string pool inside the APK ๐งตbadgingโ prints the label and icon for the app declared in the APK ๐ท๏ธpermissionsโ prints the permissions from the APK ๐resourcesโ prints the resource table from the APK ๐ฆconfigurationsโ prints the configurations in the APK โ๏ธxmltreeโ prints the compiled XMLs in the assets you give it ๐ณxmlstringsโ prints the strings of the compiled XML assets you give it ๐
Now for package, which is the big main-character command ๐
aapt p[ackage] [-d] [-f] [-m] [-u] [-v] [-x] [-z] [-M AndroidManifest.xml]
[-0 extension [-0 extension ...]] [-g tolerance] [-j jarfile]
[--debug-mode] [--min-sdk-version VAL] [--target-sdk-version VAL]
[--app-version VAL] [--app-version-name TEXT] [--custom-package VAL]
[--rename-manifest-package PACKAGE]
[--rename-instrumentation-target-package PACKAGE]
[--utf16] [--auto-add-overlay]
[--max-res-version VAL]
[-I base-package [-I base-package ...]]
[-A asset-source-dir] [-G class-list-file] [-P public-definitions-file]
[-S resource-sources [-S resource-sources ...]]
[-F apk-file] [-J R-file-dir]
[--product product1,product2,...]
[-c CONFIGS] [--preferred-configurations CONFIGS]
[raw-files-dir [raw-files-dir] ...]
[--output-text-symbols DIR]
This one packages up the android resources! It reads assets and resources supplied through the -M, -A, -S, or raw-files-dir arguments. The -J, -P, -F, and -R options decide which files get output ๐
Next up, remove and add, which are basically your closet organizers for archives ๐๏ธโ
aapt r[emove] [-v] file.{zip,jar,apk} file1 [file2 ...]
Deletes the specified files from a Zip-compatible archive ๐ซ
aapt a[dd] [-v] file.{zip,jar,apk} file1 [file2 ...]
Adds the specified files to a Zip-compatible archive ๐
Now for the PNG preprocessing commands, crunch and singleCrunch ๐ผ๏ธ
aapt c[runch] [-v] -S resource-sources ... -C output-folder ...
Does PNG preprocessing on one or several resource folders and stores the results in the output folder โจ
aapt s[ingleCrunch] [-v] -i input-file -o outputfile
Does PNG preprocessing on a single file ๐ธ
Last but not least, version ๐งพ
aapt v[ersion]
Prints the program version. Simple, iconic, no notes ๐
๐ DESCRIPTION ๐
okay so, the Android Asset Packaging Tool (aapt) takes your application resource files, like the AndroidManifest.xml file and the XML files for your Activities, and compiles them. It also produces an R.java so you can reference your resources from your Java code. literally so useful ๐ญ๐ซถ
๐ OPTIONS ๐
Here's a summary of the options, bestie ๐
-aโ prints Android-specific data (resources, manifest) when listing ๐-cโ picks which configurations to include. The default is all configurations. The value is a comma-separated list of configuration values, and locales can be a language or a language-region pair. Some examples:
en
port,en
port,land,en_US
The special locale zz_ZZ can go on the list too! It does pseudolocalization on the default locale and modifies all the strings so you can spot the ones that missed the internationalization process ๐ For example:
port,land,zz_ZZ
-dโ one or more device assets to include, separated by commas ๐ฑ-fโ force overwrite of existing files ๐ฅ-gโ specifies a pixel tolerance to force images to grayscale. Default is0๐ฉถ-jโ specifies a jar or zip file containing classes to include ๐ซ-kโ junk the path of any file(s) you add ๐๏ธ-mโ makes package directories under the location specified by-J๐-uโ updates existing packages (adds new, replaces older, removes deleted files) ๐-vโ verbose output, for when you want ALL the tea โ-xโ creates extending (non-application) resource IDs ๐งฉ-zโ requires localization of resource attributes marked withlocalization="suggested"๐-Aโ an additional directory where raw asset files can be found ๐๏ธ-Gโ a file to output proguard options into ๐งน-Fโ specifies the apk file to output ๐ฆ-Iโ adds an existing package to the base include set โ-Jโ specifies where to output theR.javaresource constant definitions ๐งฎ-Mโ specifies the full path to theAndroidManifest.xmlto include in the zip ๐-Pโ specifies where to output the public resource definitions ๐-Sโ a directory where resources can be found. Multiple directories get scanned, and the first match found (left to right) takes precedence ๐-0โ specifies an additional extension for which those files will not be stored compressed in the.apk. An empty string means not to compress any files at all ๐ซง
Now for the long options, the ones with the big energy โจ
--debug-modeโ insertsandroid:debuggable="true"into the application node of the manifest, making the application debuggable even on production devices.
โ ๏ธ bestie, this one is a real caveat! Because it makes the app debuggable even on production devices, use it carefully ๐
--min-sdk-versionโ insertsandroid:minSdkVersioninto the manifest. If the version is 7 or higher, the default encoding for resources will be UTF-8 ๐ค--target-sdk-versionโ insertsandroid:targetSdkVersioninto the manifest ๐ฏ--max-res-versionโ ignores versioned resource directories above the given value ๐ โโ๏ธ--valuesโ when used with "dump resources", also includes resource values ๐--version-codeโ insertsandroid:versionCodeinto the manifest ๐ข--version-nameโ insertsandroid:versionNameinto the manifest ๐ท๏ธ--custom-packageโ generatesR.javainto a different package ๐--extra-packagesโ generatesR.javafor libraries. Separate libraries with':'๐--generate-dependenciesโ generates dependency files in the same directories forR.javaand the resource package ๐ธ๏ธ--auto-add-overlayโ automatically adds resources that are only in overlays ๐ช--preferred-configurationsโ like the-coption for filtering out unneeded configurations, but it only expresses a preference. If there's no resource available with the preferred configuration, it won't be stripped ๐โโ๏ธ--rename-manifest-packageโ rewrites the manifest so its package name is the one given here. Relative class names (for example.Foo) get changed to absolute names with the old package, so the code doesn't have to change ๐ชช--rename-instrumentation-target-packageโ rewrites the manifest so all of its instrumentation components target the given package. It's super useful alongside--rename-manifest-packageto fix tests against a package that got renamed ๐งช--productโ specifies which variant to choose for strings that have product variants ๐๏ธ--utf16โ changes the default encoding for resources to UTF-16. Only useful when the API level is set to 7 or higher, where the default encoding is UTF-8 ๐ซ--non-constant-idโ makes the resource IDs non-constant. This is required to make an R java class that doesn't contain the final value, but is used to make reusable compiled libraries that need to access resources ๐--error-on-failed-insertโ forces aapt to return an error if it fails to insert values into the manifest with--debug-mode,--min-sdk-version,--target-sdk-version,--version-code, and--version-name. Insertion typically fails if the manifest already defines the attribute ๐จ--output-text-symbolsโ generates a text file containing the resource symbols of the R class in the specified folder ๐--ignore-assetsโ assets to be ignored ๐
๐ฆ AUTHOR ๐ฆ
aapt was written by The Android Open Source Project. the real MVPs ๐๐ซถ
That's the whole tea, bestie! ๐ This page is for aapt(1) and it was last updated October 15, 2014 ๐ธโจ
๐ฆ where this page comes from
- debian bookworm: aapt 1:10.0.0+r36-10 ยท Apache-2.0
- debian trixie: aapt 1:14~beta1-3 ยท Apache-2.0
- ubuntu jammy: aapt 1:10.0.0+r36-3 ยท Apache-2.0
- ubuntu noble: aapt 1:14~beta1-2build3 ยท Apache-2.0
- ubuntu questing: aapt 1:14~beta1-3
- ubuntu resolute: aapt 1:14~beta1-5 ยท Apache-2.0
- ubuntu stonking: aapt 1:14~beta1-5 ยท Apache-2.0
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms