Struct crossbundle_tools::types::Aapt2Link
source · [−]pub struct Aapt2Link { /* private fields */ }
Expand description
Link
In the link phase, AAPT2
merges all the intermediate files generated from the
compilation phase such as resource tables, binary XML files, and processed
PNG files and packages them into a single APK. Additionally, other auxiliary
files like R.java
and ProGuard rules files can be generated during this phase.
However, the generated APK does not contain DEX bytecode and is unsigned.
That is, you can’t deploy this APK to a device. If you’re not using the Android
Gradle Plugin to [build your app from the command line
], you can use other command
line tools, such as [d8
] to compile Java bytecode into DEX bytecode and
[apksigner
] to sign your APK.
Link syntax
The general syntax for using link is as follows:
`aapt2 link path-to-input-files [options] -o`
`outputdirectory/outputfilename.apk --manifest AndroidManifest.xml`
In the following example, AAPT2 merges the two intermediate files -
drawable_Image.flat
and values_values.arsc.flat
, and the AndroidManifest.xml
file. AAPT2
links the result against android.jar
file which holds the resources
defined in the android package:
`aapt2 link -o output.apk
-I android_sdk/platforms/android_version/android.jar
compiled/res/values_values.arsc.flat
compiled/res/drawable_Image.flat --manifest /path/to/AndroidManifest.xml -v`
Implementations
sourceimpl Aapt2Link
impl Aapt2Link
sourcepub fn new(inputs: &[PathBuf], output_apk: &Path, manifest: &Path) -> Aapt2Link
pub fn new(inputs: &[PathBuf], output_apk: &Path, manifest: &Path) -> Aapt2Link
Specifies the output path for the linked resource APK.
This is a required flag because you must specify the path for the output APK that can hold the linked resources.
Specifies the path to the Android manifest file to build.
This is a required flag because the manifest file encloses essential information about your app like package name and application ID
sourcepub fn new_from_compiled_res(
compiled_res: Option<PathBuf>,
output_apk: &Path,
manifest: &Path
) -> Aapt2Link
pub fn new_from_compiled_res(
compiled_res: Option<PathBuf>,
output_apk: &Path,
manifest: &Path
) -> Aapt2Link
Specifies the output path for the linked resource APK.
This is a required flag because you must specify the path for the output APK that can hold the linked resources.
Specifies the path to the Android manifest file to build.
This is a required flag because the manifest file encloses essential information about your app like package name and application ID
sourcepub fn proguard_main_dex(&mut self, proguard_main_dex: PathBuf) -> &mut Aapt2Link
pub fn proguard_main_dex(&mut self, proguard_main_dex: PathBuf) -> &mut Aapt2Link
Generates output file for ProGuard rules for the main dex
sourcepub fn proguard_minimal_keep_rules(
&mut self,
proguard_minimal_keep_rules: bool
) -> &mut Aapt2Link
pub fn proguard_minimal_keep_rules(
&mut self,
proguard_minimal_keep_rules: bool
) -> &mut Aapt2Link
Generate a minimal set of Proguard keep rules
sourcepub fn no_resource_removal(
&mut self,
no_resource_removal: bool
) -> &mut Aapt2Link
pub fn no_resource_removal(
&mut self,
no_resource_removal: bool
) -> &mut Aapt2Link
Disables automatic removal of resources without
sourcepub fn package_identifier(&mut self, package_identifier: bool) -> &mut Aapt2Link
pub fn package_identifier(&mut self, package_identifier: bool) -> &mut Aapt2Link
Legacy flag that specifies to use the package identifier 0x01
sourcepub fn product(&mut self, product: PathBuf) -> &mut Aapt2Link
pub fn product(&mut self, product: PathBuf) -> &mut Aapt2Link
Comma separated list of product names to keep
sourcepub fn no_xml_namespaces(&mut self, no_xml_namespaces: bool) -> &mut Aapt2Link
pub fn no_xml_namespaces(&mut self, no_xml_namespaces: bool) -> &mut Aapt2Link
Removes XML namespace prefix and URI information
sourcepub fn version_code_major(&mut self, version_code_major: u32) -> &mut Aapt2Link
pub fn version_code_major(&mut self, version_code_major: u32) -> &mut Aapt2Link
Version code major (integer) to inject into the AndroidManifest.xml
if none is
present
sourcepub fn version_name(&mut self, version_name: String) -> &mut Aapt2Link
pub fn version_name(&mut self, version_name: String) -> &mut Aapt2Link
Version name to inject into the AndroidManifest.xml
if none is present
sourcepub fn replace_version(&mut self, replace_version: bool) -> &mut Aapt2Link
pub fn replace_version(&mut self, replace_version: bool) -> &mut Aapt2Link
If --version-code
and/or --version-name
are specified, these values will
replace any value already in the manifest. By default, nothing is changed if
the manifest already defines these attributes
sourcepub fn compile_sdk_version_code(
&mut self,
compile_sdk_version_code: u32
) -> &mut Aapt2Link
pub fn compile_sdk_version_code(
&mut self,
compile_sdk_version_code: u32
) -> &mut Aapt2Link
Version code (integer) to inject into the AndroidManifest.xml
if none is present
Generates a shared Android runtime library
sourcepub fn static_lib(&mut self, static_lib: bool) -> &mut Aapt2Link
pub fn static_lib(&mut self, static_lib: bool) -> &mut Aapt2Link
Generate a static Android library
sourcepub fn no_static_lib_packages(
&mut self,
no_static_lib_packages: bool
) -> &mut Aapt2Link
pub fn no_static_lib_packages(
&mut self,
no_static_lib_packages: bool
) -> &mut Aapt2Link
Merge all library resources under the app’s package
sourcepub fn no_proguard_location_reference(
&mut self,
no_proguard_location_reference: bool
) -> &mut Aapt2Link
pub fn no_proguard_location_reference(
&mut self,
no_proguard_location_reference: bool
) -> &mut Aapt2Link
Keep proguard rules files from having a reference to the source file
sourcepub fn private_symbols(&mut self, private_symbols: String) -> &mut Aapt2Link
pub fn private_symbols(&mut self, private_symbols: String) -> &mut Aapt2Link
Package name to use when generating R.java
for private symbols. If not
specified, public and private symbols will use the application’s package name
sourcepub fn override_styles_instead_of_overlaying(
&mut self,
override_styles_instead_of_overlaying: bool
) -> &mut Aapt2Link
pub fn override_styles_instead_of_overlaying(
&mut self,
override_styles_instead_of_overlaying: bool
) -> &mut Aapt2Link
Causes styles defined in -R
resources to replace previous definitions instead of
merging into them
sourcepub fn rename_resources_package(
&mut self,
rename_resources_package: String
) -> &mut Aapt2Link
pub fn rename_resources_package(
&mut self,
rename_resources_package: String
) -> &mut Aapt2Link
Renames the package in resources table
sourcepub fn android_jar(&mut self, android_jar: PathBuf) -> &mut Aapt2Link
pub fn android_jar(&mut self, android_jar: PathBuf) -> &mut Aapt2Link
Provides the path to the platform’s android.jar
or other APKs like
framework-res.apk
which might be useful while building features. This flag is
required if you are using attributes with android namespace (for example,
android:id) in your resource files
sourcepub fn assets(&mut self, assets: PathBuf) -> &mut Aapt2Link
pub fn assets(&mut self, assets: PathBuf) -> &mut Aapt2Link
Specifies an assets directory to be included in the APK.
You can use this directory to store original unprocessed files. To learn more,
read Accessing original
files.
sourcepub fn individual_flat(&mut self, individual_flat: PathBuf) -> &mut Aapt2Link
pub fn individual_flat(&mut self, individual_flat: PathBuf) -> &mut Aapt2Link
Pass individual .flat
file to link, using overlay
semantics without using the
<add-resource>
tag.
When you a provide a resource file that overlays (extends or modifies) an existing file, the last conflicting resource given is used
sourcepub fn package_id(&mut self, package_id: String) -> &mut Aapt2Link
pub fn package_id(&mut self, package_id: String) -> &mut Aapt2Link
Specifies the package ID to use for your app.
The package ID that you specify must be greater than or equal to 0x7f unless used
in combination with --allow-reserved-package-id
sourcepub fn allow_reserved_package_id(
&mut self,
allow_reserved_package_id: bool
) -> &mut Aapt2Link
pub fn allow_reserved_package_id(
&mut self,
allow_reserved_package_id: bool
) -> &mut Aapt2Link
Allows the use of a reserved package ID.
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
sourcepub fn java(&mut self, java: PathBuf) -> &mut Aapt2Link
pub fn java(&mut self, java: PathBuf) -> &mut Aapt2Link
Specifies the directory in which to generate R.java
sourcepub fn proguard_options(&mut self, proguard_options: PathBuf) -> &mut Aapt2Link
pub fn proguard_options(&mut self, proguard_options: PathBuf) -> &mut Aapt2Link
Generates output file for ProGuard rules
sourcepub fn proguard_conditional_keep_rules(
&mut self,
proguard_conditional_keep_rules: bool
) -> &mut Aapt2Link
pub fn proguard_conditional_keep_rules(
&mut self,
proguard_conditional_keep_rules: bool
) -> &mut Aapt2Link
Output file for generated Proguard rules for the main dex
sourcepub fn no_auto_version(&mut self, no_auto_version: bool) -> &mut Aapt2Link
pub fn no_auto_version(&mut self, no_auto_version: bool) -> &mut Aapt2Link
Disables automatic style and layout SDK versioning
sourcepub fn no_version_vectors(&mut self, no_version_vectors: bool) -> &mut Aapt2Link
pub fn no_version_vectors(&mut self, no_version_vectors: bool) -> &mut Aapt2Link
Disables automatic versioning of vector drawables. Use this only when building your APK with the Vector Drawable Library
sourcepub fn no_version_transitions(
&mut self,
no_version_transitions: bool
) -> &mut Aapt2Link
pub fn no_version_transitions(
&mut self,
no_version_transitions: bool
) -> &mut Aapt2Link
Disables automatic versioning of transition resources. Use this only when building your APK with Transition Support library
sourcepub fn no_resource_deduping(
&mut self,
no_resource_deduping: bool
) -> &mut Aapt2Link
pub fn no_resource_deduping(
&mut self,
no_resource_deduping: bool
) -> &mut Aapt2Link
Disables automatic de-duplication of resources with identical values across compatible configurations
sourcepub fn enable_sparse_encoding(
&mut self,
enable_sparse_encoding: bool
) -> &mut Aapt2Link
pub fn enable_sparse_encoding(
&mut self,
enable_sparse_encoding: bool
) -> &mut Aapt2Link
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
sourcepub fn suggested_strings(&mut self, suggested_strings: bool) -> &mut Aapt2Link
pub fn suggested_strings(&mut self, suggested_strings: bool) -> &mut Aapt2Link
Requires localization of strings marked ‘suggested’
sourcepub fn config(&mut self, config: String) -> &mut Aapt2Link
pub fn config(&mut self, config: String) -> &mut Aapt2Link
Provides a list of configurations separated by commas.
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).
sourcepub fn preferred_density(&mut self, preferred_density: i32) -> &mut Aapt2Link
pub fn preferred_density(&mut self, preferred_density: i32) -> &mut Aapt2Link
Allows AAPT2
to select the closest matching density and strip out all others.
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.
sourcepub fn output_to_dir(&mut self, output_to_dir: &Path) -> &mut Aapt2Link
pub fn output_to_dir(&mut self, output_to_dir: &Path) -> &mut Aapt2Link
Outputs the APK contents to a directory specified by -o
.
If you get any errors using this flag, you can resolve them by upgrading to
Android SDK Build Tools 28.0.0 or higher
.
sourcepub fn min_sdk_version(&mut self, min_sdk_version: u32) -> &mut Aapt2Link
pub fn min_sdk_version(&mut self, min_sdk_version: u32) -> &mut Aapt2Link
Sets the default minimum SDK version to use for AndroidManifest.xml
sourcepub fn target_sdk_version(&mut self, target_sdk_version: u32) -> &mut Aapt2Link
pub fn target_sdk_version(&mut self, target_sdk_version: u32) -> &mut Aapt2Link
Sets the default target SDK version to use for AndroidManifest.xml
sourcepub fn version_code(&mut self, version_code: u32) -> &mut Aapt2Link
pub fn version_code(&mut self, version_code: u32) -> &mut Aapt2Link
Specifies the version code (integer) to inject into the AndroidManifest.xml
if
none is present
sourcepub fn compile_sdk_version_name(
&mut self,
compile_sdk_version_name: String
) -> &mut Aapt2Link
pub fn compile_sdk_version_name(
&mut self,
compile_sdk_version_name: String
) -> &mut Aapt2Link
Specifies the version name to inject into the AndroidManifest.xml if none is present
sourcepub fn proto_format(&mut self, proto_format: bool) -> &mut Aapt2Link
pub fn proto_format(&mut self, proto_format: bool) -> &mut Aapt2Link
Generates compiled resources in Protobuf format.
Suitable as input to the bundle tool
for generating an Android App Bundle.
sourcepub fn non_final_ids(&mut self, non_final_ids: bool) -> &mut Aapt2Link
pub fn non_final_ids(&mut self, non_final_ids: bool) -> &mut Aapt2Link
Generates R.java
with non-final resource IDs (references to the IDs from app’s
code will not get inlined during kotlinc/javac compilation)
sourcepub fn emit_ids(&mut self, emit_ids: PathBuf) -> &mut Aapt2Link
pub fn emit_ids(&mut self, emit_ids: PathBuf) -> &mut Aapt2Link
Emits a file at the given path with a list of names of resource types and their ID
mappings. It is suitable to use with --stable-ids
sourcepub fn stable_ids(&mut self, stable_ids: PathBuf) -> &mut Aapt2Link
pub fn stable_ids(&mut self, stable_ids: PathBuf) -> &mut Aapt2Link
Consumes the file generated with --emit-ids
containing the list of names of
resource types and their assigned IDs.
This option allows assigned IDs to remain stable even when you delete or add new resources while linking
sourcepub fn custom_package(&mut self, custom_package: PathBuf) -> &mut Aapt2Link
pub fn custom_package(&mut self, custom_package: PathBuf) -> &mut Aapt2Link
Specifies custom Java package under which to generate R.java
sourcepub fn extra_packages(&mut self, extra_packages: PathBuf) -> &mut Aapt2Link
pub fn extra_packages(&mut self, extra_packages: PathBuf) -> &mut Aapt2Link
Generates the same R.java
file but with different package names
sourcepub fn add_javadoc_annotation(
&mut self,
add_javadoc_annotation: String
) -> &mut Aapt2Link
pub fn add_javadoc_annotation(
&mut self,
add_javadoc_annotation: String
) -> &mut Aapt2Link
Adds a JavaDoc annotation to all generated Java classes
sourcepub fn output_text_symbols(
&mut self,
output_text_symbols: PathBuf
) -> &mut Aapt2Link
pub fn output_text_symbols(
&mut self,
output_text_symbols: PathBuf
) -> &mut Aapt2Link
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
sourcepub fn auto_add_overlay(&mut self, auto_add_overlay: bool) -> &mut Aapt2Link
pub fn auto_add_overlay(&mut self, auto_add_overlay: bool) -> &mut Aapt2Link
Allows the addition of new resources in overlays without using the
sourcepub fn rename_manifest_package(
&mut self,
rename_manifest_package: String
) -> &mut Aapt2Link
pub fn rename_manifest_package(
&mut self,
rename_manifest_package: String
) -> &mut Aapt2Link
Renames the package in AndroidManifest.xml
sourcepub fn rename_instrumentation_target_package(
&mut self,
rename_instrumentation_target_package: String
) -> &mut Aapt2Link
pub fn rename_instrumentation_target_package(
&mut self,
rename_instrumentation_target_package: String
) -> &mut Aapt2Link
Changes the name of the target package for instrumentation
.
It should be used in conjunction with --rename-manifest-package
.
sourcepub fn no_compress(&mut self, no_compress: bool) -> &mut Aapt2Link
pub fn no_compress(&mut self, no_compress: bool) -> &mut Aapt2Link
Do not compress any resources
sourcepub fn keep_raw_values(&mut self, keep_raw_values: bool) -> &mut Aapt2Link
pub fn keep_raw_values(&mut self, keep_raw_values: bool) -> &mut Aapt2Link
Preserve raw attribute values in xml files
sourcepub fn extension(&mut self, extension: String) -> &mut Aapt2Link
pub fn extension(&mut self, extension: String) -> &mut Aapt2Link
Specifies the extensions of files that you do not want to compress
sourcepub fn no_compress_regex(&mut self, no_compress_regex: String) -> &mut Aapt2Link
pub fn no_compress_regex(&mut self, no_compress_regex: String) -> &mut Aapt2Link
Do not compress extensions matching the regular expression. Remember to use the ‘$’ symbol for end of line. Uses a case-sensitive ECMAScriptregular expression grammar
sourcepub fn warn_manifest_validation(
&mut self,
warn_manifest_validation: bool
) -> &mut Aapt2Link
pub fn warn_manifest_validation(
&mut self,
warn_manifest_validation: bool
) -> &mut Aapt2Link
Treat manifest validation errors as warnings
sourcepub fn split(&mut self, split: PathBuf) -> &mut Aapt2Link
pub fn split(&mut self, split: PathBuf) -> &mut Aapt2Link
Splits resources based on a set of configurations to generate a different version of the APK.
You must specify the path to the output APK along with the set of configurations
sourcepub fn strict_visibility(&mut self, strict_visibility: bool) -> &mut Aapt2Link
pub fn strict_visibility(&mut self, strict_visibility: bool) -> &mut Aapt2Link
Do not allow overlays with different visibility levels
sourcepub fn trace_folder(&mut self, trace_folder: String) -> &mut Aapt2Link
pub fn trace_folder(&mut self, trace_folder: String) -> &mut Aapt2Link
Generate systrace json trace fragment to specified folder
sourcepub fn exclude_sources(&mut self, exclude_sources: bool) -> &mut Aapt2Link
pub fn exclude_sources(&mut self, exclude_sources: bool) -> &mut Aapt2Link
Do not serialize source file information when generating resources in Protobuf format
sourcepub fn merge_only(&mut self, merge_only: bool) -> &mut Aapt2Link
pub fn merge_only(&mut self, merge_only: bool) -> &mut Aapt2Link
Only merge the resources, without verifying resource references. This flag should
only be used together with the --static-lib
flag
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Aapt2Link
impl Send for Aapt2Link
impl Sync for Aapt2Link
impl Unpin for Aapt2Link
impl UnwindSafe for Aapt2Link
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more