Title: Theory / Unimportant / CS / Development / Android / AAPT2
On every note of this deck, unless a note says otherwise:
Page: https://developer.android.com/studio/command-line/aapt2
Context: android

Name: Android asset packaging tool
Definition: a build tool that Android Studio and Android Gradle Plugin use to compile and package your app’s resources.
Page: https://developer.android.com/studio/command-line/aapt2
Context: android
Abbreviation: AAPT2

Fla: compile path-to-input-files
Effect: compile the files at path-to-input-files
Prefix: aapt2

Fla: -o dir
Effect: put output at directory dir
Prefix: aapt2 compile path-to-input-files

Fla: --dir directory
Effect: Specifies the directory to scan for resources.
Prefix: aapt2 compile path-to-input-files
Extra: Although you can use this flag to compile multiple resource files with one command, it disables the benefits of incremental compilation and thus, should not be used for large projects.

Fla: --pseudo-localize
Effect: Generates pseudo-localized versions of default strings, such as en-XA and en-XB.
Prefix: aapt2 compile path-to-input-files

Fla: --no-crunch
Effect: Disables PNG processing.
Prefix: aapt2 compile path-to-input-files
Extra: Use this option if you have already processed the PNG files, or if you are creating debug builds that do not require file size reduction. Enabling this option results in a faster execution, but increases the output file size.

Fla: --legacy
Effect: Treats errors that are permissible when using earlier versions of AAPT as warnings.
Prefix: aapt2 compile path-to-input-files
Extra: This flag should be used for unexpected compile time errors. To resolve known behavior changes that you might get while using AAPT2, read Behavior changes in AAPT2.

Fla: -v
Effect: enable verbose logging
Prefix: aapt2 compile path-to-input-files

Fla: link path-to-input-files
Effect: link the files in path-to-input-files to generate a apk
Prefix: aapt2

Fla: --manifest foo.xml
Effect: use the manifest foo.xml
Prefix: aapt2 link path-to-input-files
Assuming: required

Fla: -o file.apk
Effect: output the apk to file file.apk
Prefix: aapt2 link path-to-input-files
Assuming: required

Fla: -I files
Effect: Provides the path to the platform's android.jar or other APKs like framework-res.apk which might be useful while building features.
Prefix: aapt2 link path-to-input-files
Assuming: This flag is required if you are using attributes with android namespace (for example, android:id) in your resource files.

Fla: -A directory
Effect: Specifies an assets directory to be included in the APK.
Prefix: aapt2 link path-to-input-files

Fla: -R file
Effect: Pass individual .flat file to link, using overlay semantics without using the <add-resource> tag.
Prefix: aapt2 link path-to-input-files
Extra: When you a provide a resource file that overlays (extends or modifies) an existing file, the last conflicting resource given is used.

Fla: --package-id package-id
Effect: Specifies the package ID to use for your app.
Prefix: aapt2 link path-to-input-files
Extra: The package ID that you specify must be greater than or equal to 0x7f unless used in combination with --allow-reserved-package-id.

Fla: --allow-reserved-package-id
Effect: Allows the use of a reserved package ID.
Prefix: aapt2 link path-to-input-files
Extra: Reserved package IDs are IDs that are normally assigned to shared libraries and are in the range from 0x02 to 0x7e inclusive. By using --allow-reserved-package-id, you can assign IDs that fall in the range of reserved package IDs.
This should only be used for packages with a min-sdk version of 26 or lower.

Fla: --java directory
Effect: Specifies the directory in which to generate R.java.
Prefix: aapt2 link path-to-input-files

Fla: --proguard proguard_options
Effect: Generates output file for ProGuard rules.
Prefix: aapt2 link path-to-input-files

Fla: --proguard-conditional-keep-rules
Effect: Generates output file for ProGuard rules for the main dex.
Prefix: aapt2 link path-to-input-files

Fla: --no-auto-version
Effect: Disables automatic style and layout SDK versioning.
Prefix: aapt2 link path-to-input-files

Fla: --no-version-vectors
Effect: Disables automatic versioning of vector drawables.
Prefix: aapt2 link path-to-input-files
Assuming: only when building your APK with the Vector Drawable Library.

Fla: --no-version-transition
Effect: Disables automatic versioning of transition support library
Prefix: aapt2 link path-to-input-files
Assuming: only when building your APK with the transition support library

Fla: --no-resource-deduping
Effect: Disables automatic de-duplication of resuorces with identical values across compatible configuration
Prefix: aapt2 link path-to-input-files

Fla: --enable-sparse-encoding
Effect: Enables encoding of sparse entries using a binary search tree. This is useful for optimization of APK size, but at the cost of resource retrieval performance.
Prefix: aapt2 link path-to-input-files

Fla: -z
Effect: Requires localization of strings marked 'suggested'.
Prefix: aapt2 link path-to-input-files

Fla: -c config
Effect: Provides a list of configurations separated by commas.
Prefix: aapt2 link path-to-input-files
Extra: For example, if you have dependencies on the support library (which contains translations for multiple languages), you can filter resources just for the given language configuration, like English or Spanish.
You must define the language configuration by a two-letter ISO 639-1 language code, optionally followed by a two letter ISO 3166-1-alpha-2 region code preceded by lowercase 'r' (for example, en-rUS).

Fla: --preferred-density density
Effect: Allows AAPT2 to select the closest matching density and strip out all others.
Prefix: aapt2 link path-to-input-files
Extra: There are several pixel density qualifiers available to use in your app, such as ldpi, hdpi, and xhdpi. When you specify a preferred density, AAPT2 selects and stores the closest matching density in the resource table and removes all others.

Fla: --output-to-dir
Effect: Outputs the APK contents to a directory specified by -o.
Prefix: aapt2 link path-to-input-files

Fla: --min-sdk-version v
Effect: Sets the default minimum SDK version to use for AndroidManifest.xml.
Prefix: aapt2 link path-to-input-files

Fla: --target-sdk-version target-sdk-version
Effect: Sets the default target SDK version to use for AndroidManifest.xml.
Prefix: aapt2 link path-to-input-files

Fla: --version-code version-code
Effect: Specifies the version code (integer) to inject into the AndroidManifest.xml if none is present.
Prefix: aapt2 link path-to-input-files

Fla: --compile-sdk-version-name compile-sdk-version-name
Effect: Specifies the version name to inject into the AndroidManifest.xml if none is present.
Prefix: aapt2 link path-to-input-files

Fla: --proto-format
Effect: Generates compiled resources in Protobuf format.
Prefix: aapt2 link path-to-input-files
Extra: Suitable as input to the bundle tool for generating an Android App Bundle.

Fla: --non-final-ids
Effect: Generates R.java with non-final resource IDs (references to the IDs from app’s code will not get inlined during kotlinc/javac compilation).
Prefix: aapt2 link path-to-input-files

Fla: --emit-ids path
Effect: Emits a file at the given path with a list of names of resource types and their ID mappings
Prefix: aapt2 link path-to-input-files
Extra: It is suitable to use with --stable-ids.

Fla: --stable-ids outputfilename.ext
Effect: Consumes the file generated with --emit-ids containing the list of names of resource types and their assigned IDs.
Prefix: aapt2 link path-to-input-files
Extra: This option allows assigned IDs to remain stable even when you delete or add new resources while linking.

Fla: --custom-package package_name
Effect: Specifies custom Java package under which to generate R.java.
Prefix: aapt2 link path-to-input-files

Fla: --extra-packages package_name
Effect: Generates the same R.java file but with different package names.
Prefix: aapt2 link path-to-input-files

Fla: --add-javadoc-annotation annotation
Effect: Adds a JavaDoc annotation to all generated Java classes.
Prefix: aapt2 link path-to-input-files

Fla: --output-text-symbols path
Effect: Generates a text file containing the resource symbols of the R class in the specified file.
You must specify the path to the output file.
Prefix: aapt2 link path-to-input-files

Fla: --auto-add-overlay
Effect: Allows the addition of new resources in overlays without using the <add-resource> tag.
Prefix: aapt2 link path-to-input-files

Fla: --rename-manifest-package manifest-package
Effect: Renames the package in AndroidManifest.xml.
Prefix: aapt2 link path-to-input-files

Fla: --rename-instrumentation-target-package instrumentation- target-package
Effect: Changes the name of the target package for instrumentation.
It should be used in conjunction with --rename-manifest-package.
Prefix: aapt2 link path-to-input-files

Fla: -0 extension
Effect: Specifies the extensions of files that you do not want to compress.
Prefix: aapt2 link path-to-input-files

Fla: --split path_1:config_1,...,path_n:config_n
Effect: Splits resources based on a set of configurations to generate a different version of the APK.
Prefix: aapt2 link path-to-input-files
Assuming: You must specify the path to the output APK along with the set of configurations.

Fla: -v
Effect: Enable increased verbosity of the output
Prefix: aapt2 link path-to-input-files

Fla: dump
Effect: printing information about the APK you generated using the link command.
Prefix: aapt2

Fla: apc filename.apk
Effect: Print the contents of the AAPT2 Container (APC) generated during compilation.
Prefix: aapt2 dump

Fla: badging
Prefix: aapt2 dump
Print: information extracted from the APK's manifest

Fla: configurations
Prefix: aapt2 dump
Print: every configuration used by a resource in the APK.

Fla: packagename
Prefix: aapt2 dump
Print: the APK's package name.

Fla: permissions
Prefix: aapt2 dump
Print: the permissinos extracted from the APK's manifest

Fla: strings
Prefix: aapt2 dump
Print: the contents of the APK's resource table string pool.

Fla: styleparents
Prefix: aapt2 dump
Print: the parents of styles used in the APK.

Fla: resources
Prefix: aapt2 dump
Print: the contents of the APK's resource table.

Fla: xmlstrings
Prefix: aapt2 dump
Print: strings from the APK's compiled xml.

Fla: xmltree
Prefix: aapt2 dump
Print: >a tree of the APK's compiled xml.

Fla: --no-values
Effect: Suppresses the output of values when displaying resource.
Prefix: aapt2 dump subcommand file.apk

Fla: --file file
Effect: Specifies a file as an argument to be dumped from the APK.
Prefix: aapt2 dump subcommand file.apk

Fla: -v
Effect: Increases verbosity of the output.
Prefix: aapt2 dump subcommand file.apk