Struct android_tools::aapt2::Aapt2Link [−][src]
pub struct Aapt2Link { /* fields omitted */ }
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
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
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
Generates output file for ProGuard rules for the main dex
Generate a minimal set of Proguard keep rules
Disables automatic removal of resources without
Legacy flag that specifies to use the package identifier 0x01
Comma separated list of product names to keep
Removes XML namespace prefix and URI information
Version code major (integer) to inject into the AndroidManifest.xml
if none is
present
Version name to inject into the AndroidManifest.xml
if none is present
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
Version code (integer) to inject into the AndroidManifest.xml
if none is present
Generates a shared Android runtime library
Generate a static Android library
Merge all library resources under the appâs package
pub fn no_proguard_location_reference(
&mut self,
no_proguard_location_reference: bool
) -> &mut Self
pub fn no_proguard_location_reference(
&mut self,
no_proguard_location_reference: bool
) -> &mut Self
Keep proguard rules files from having a reference to the source file
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
pub fn override_styles_instead_of_overlaying(
&mut self,
override_styles_instead_of_overlaying: bool
) -> &mut Self
pub fn override_styles_instead_of_overlaying(
&mut self,
override_styles_instead_of_overlaying: bool
) -> &mut Self
Causes styles defined in -R
resources to replace previous definitions instead of
merging into them
Renames the package in resources table
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
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.
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
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
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
Specifies the directory in which to generate R.java
Generates output file for ProGuard rules
pub fn proguard_conditional_keep_rules(
&mut self,
proguard_conditional_keep_rules: bool
) -> &mut Self
pub fn proguard_conditional_keep_rules(
&mut self,
proguard_conditional_keep_rules: bool
) -> &mut Self
Output file for generated Proguard rules for the main dex
Disables automatic style and layout SDK versioning
Disables automatic versioning of vector drawables. Use this only when building your APK with the Vector Drawable Library
Disables automatic versioning of transition resources. Use this only when building your APK with Transition Support library
Disables automatic de-duplication of resources with identical values across compatible configurations
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
Requires localization of strings marked âsuggestedâ
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).
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.
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
.
Sets the default minimum SDK version to use for AndroidManifest.xml
Sets the default target SDK version to use for AndroidManifest.xml
Specifies the version code (integer) to inject into the AndroidManifest.xml
if
none is present
Specifies the version name to inject into the AndroidManifest.xml if none is present
Generates compiled resources in Protobuf format.
Suitable as input to the bundle tool
for generating an Android App Bundle.
Generates R.java
with non-final resource IDs (references to the IDs from appâs
code will not get inlined during kotlinc/javac compilation)
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
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
Specifies custom Java package under which to generate R.java
Generates the same R.java
file but with different package names
Adds a JavaDoc annotation to all generated Java classes
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
Allows the addition of new resources in overlays without using the
Renames the package in AndroidManifest.xml
pub fn rename_instrumentation_target_package(
&mut self,
rename_instrumentation_target_package: String
) -> &mut Self
pub fn rename_instrumentation_target_package(
&mut self,
rename_instrumentation_target_package: String
) -> &mut Self
Changes the name of the target package for instrumentation
.
It should be used in conjunction with --rename-manifest-package
.
Do not compress any resources
Preserve raw attribute values in xml files
Specifies the extensions of files that you do not want to compress
Do not compress extensions matching the regular expression. Remember to use the â$â symbol for end of line. Uses a case-sensitive ECMAScriptregular expression grammar
Treat manifest validation errors as warnings
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
Do not allow overlays with different visibility levels
Generate systrace json trace fragment to specified folder
Do not serialize source file information when generating resources in Protobuf format
Only merge the resources, without verifying resource references. This flag should
only be used together with the --static-lib
flag